b84320b45e
1. Various idiomatic Go and TypeScript fixes 2. Add an integration test that end-to-end roundtrips dependency information for a simple Pulumi program 3. Add an additional test assert that tests that dependency information comes from the language host as expected
47 lines
No EOL
1.2 KiB
TypeScript
47 lines
No EOL
1.2 KiB
TypeScript
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
|
|
|
import * as pulumi from "@pulumi/pulumi";
|
|
|
|
class Provider implements pulumi.dynamic.ResourceProvider {
|
|
public readonly create: (inputs: any) => Promise<pulumi.dynamic.CreateResult>;
|
|
|
|
constructor(num: number) {
|
|
this.create = async (inputs: any) => {
|
|
return {
|
|
id: "0",
|
|
outs: { value: num }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
class FirstResource extends pulumi.dynamic.Resource {
|
|
public readonly value: pulumi.Output<number>;
|
|
|
|
private static provider: Provider = new Provider(42);
|
|
constructor(name: string) {
|
|
super(FirstResource.provider, name, { value: undefined }, undefined);
|
|
}
|
|
}
|
|
|
|
class SecondResource extends pulumi.dynamic.Resource {
|
|
public readonly dep: pulumi.Output<number>;
|
|
|
|
private static provider: Provider = new Provider(99);
|
|
|
|
constructor(name: string, prop: pulumi.Input<number>) {
|
|
super(SecondResource.provider, name, {dep: prop}, undefined);
|
|
}
|
|
}
|
|
|
|
const first = new FirstResource("first");
|
|
first.value.apply(v => {
|
|
console.log(`first.value: ${v}`);
|
|
});
|
|
|
|
|
|
const second = new SecondResource("second", first.value);
|
|
second.dep.apply(d => {
|
|
console.log(`second.dep: ${d}`);
|
|
}); |