pulumi/sdk/nodejs/tests/runtime/props.spec.ts
Pat Gavlin 16f1930069
Pass "special" properties to Invoke. (#1277)
Rather than filtering out the `id` and `urn` properties when serializing
the inputs to an invoke, pass these properties along. This enables the
use of invoke endpoints that accepts these as inputs (e.g. the endpoint
that backs `aws.ec2.getSubnet`).
2018-05-01 15:05:42 -07:00

33 lines
1.3 KiB
TypeScript

// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
import * as assert from "assert";
import { Inputs, runtime } from "../../index";
import { asyncTest } from "../util";
const gstruct = require("google-protobuf/google/protobuf/struct_pb.js");
describe("runtime", () => {
describe("transferProperties", () => {
it("marshals basic properties correctly", asyncTest(async () => {
const inputs: Inputs = {
"aNum": 42,
"bStr": "a string",
"cUnd": undefined,
"dArr": Promise.resolve([ "x", 42, Promise.resolve(true), Promise.resolve(undefined) ]),
"id": "foo",
"urn": "bar",
};
// Serialize and then deserialize all the properties, checking that they round-trip as expected.
const transfer = gstruct.Struct.fromJavaScript(
await runtime.serializeProperties("test", inputs));
const result = runtime.deserializeProperties(transfer);
assert.equal(result.aNum, 42);
assert.equal(result.bStr, "a string");
assert.equal(result.cUnd, undefined);
assert.deepEqual(result.dArr, [ "x", 42, true, undefined ]);
assert.equal(result.id, "foo");
assert.equal(result.urn, "bar");
}));
});
});