Add a test for derived inputs.

This commit is contained in:
Pat Gavlin 2018-01-22 11:47:14 -08:00
parent 600b267318
commit 172a192e52
7 changed files with 119 additions and 0 deletions

View file

@ -0,0 +1,3 @@
/bin/
/node_modules/

View file

@ -0,0 +1,4 @@
name: derived-inputs
description: Tests a Pulumi program with one resource's inputs derived from other another resource's outputs.
runtime: nodejs

View file

@ -0,0 +1,34 @@
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
import * as pulumi from "pulumi";
import * as dynamic from "pulumi/dynamic";
const sleep = require("sleep-promise");
const assert = require("assert");
class InputProvider implements dynamic.ResourceProvider {
check = (olds: any, news: any) => {
assert(news.input);
return Promise.resolve({ inputs: news });
};
diff = (id: pulumi.ID, olds: any, news: any) => Promise.resolve({});
create = (inputs: any) => Promise.resolve({ id: "0" });
update = (id: string, olds: any, news: any) => Promise.resolve({});
delete = (id: pulumi.ID, props: any) => Promise.resolve();
}
class InputResource extends dynamic.Resource {
constructor(name: string, input: pulumi.ComputedValue<string>) {
super(new InputProvider(), name, { input: input }, undefined);
}
}
(async () => {
try {
const a = new InputResource("a", "string");
const b = new InputResource("b", a.urn);
} catch (err) {
console.error(err);
process.exit(-1);
}
})();

View file

@ -0,0 +1,17 @@
{
"name": "minimal",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"@types/minimist": "^1.2.0",
"@types/node": "^8.0.25",
"typescript": "^2.5.3"
},
"dependencies": {
"sleep-promise": "^2.0.0",
"assert": "^1.4.1"
}
}

View file

@ -0,0 +1,22 @@
{
"compilerOptions": {
"outDir": "bin",
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"stripInternal": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true,
"strictNullChecks": true
},
"files": [
"index.ts"
]
}

View file

@ -0,0 +1,35 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/minimist@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
"@types/node@^8.0.25":
version "8.0.47"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.47.tgz#968e596f91acd59069054558a00708c445ca30c2"
assert@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91"
dependencies:
util "0.10.3"
inherits@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"
sleep-promise@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/sleep-promise/-/sleep-promise-2.0.0.tgz#e7e798dfe56c044da85882d76d22a99804663c41"
typescript@^2.5.3:
version "2.5.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.3.tgz#df3dcdc38f3beb800d4bc322646b04a3f6ca7f0d"
util@0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9"
dependencies:
inherits "2.0.1"

View file

@ -61,6 +61,10 @@ func TestExamples(t *testing.T) {
}
},
},
{
Dir: path.Join(cwd, "dynamic-provider/derived-inputs"),
Dependencies: []string{"pulumi"},
},
{
Dir: path.Join(cwd, "formattable"),
Dependencies: []string{"pulumi"},