@pulumi/pulumi 3.135.2-alpha.xaa9ca8a → 3.135.2-alpha.xcc59acd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/package.json +1 -1
  2. package/version.js +1 -1
  3. package/npm/testdata/nested/project/index.d.ts +0 -0
  4. package/npm/testdata/nested/project/index.js +0 -16
  5. package/npm/testdata/nested/project/index.js.map +0 -1
  6. package/tests/automation/cmd.spec.d.ts +0 -1
  7. package/tests/automation/cmd.spec.js +0 -186
  8. package/tests/automation/cmd.spec.js.map +0 -1
  9. package/tests/automation/data/correct_project/Pulumi.yaml +0 -3
  10. package/tests/automation/data/import/Pulumi.yaml +0 -2
  11. package/tests/automation/data/import/expected_generated_code.txt +0 -11
  12. package/tests/automation/data/json/Pulumi.dev.json +0 -9
  13. package/tests/automation/data/json/Pulumi.json +0 -5
  14. package/tests/automation/data/nested_config/Pulumi.dev.yaml +0 -11
  15. package/tests/automation/data/nested_config/Pulumi.yaml +0 -3
  16. package/tests/automation/data/tcfg/Pulumi.yaml +0 -4
  17. package/tests/automation/data/tcfg/index.ts +0 -1
  18. package/tests/automation/data/tcfg/package-lock.json +0 -3062
  19. package/tests/automation/data/tcfg/package.json +0 -9
  20. package/tests/automation/data/tcfg/tsconfig.json +0 -16
  21. package/tests/automation/data/testproj/Pulumi.yaml +0 -3
  22. package/tests/automation/data/testproj/go.mod +0 -71
  23. package/tests/automation/data/testproj/go.sum +0 -299
  24. package/tests/automation/data/testproj/main.go +0 -19
  25. package/tests/automation/data/testproj_dotnet/Program.cs +0 -12
  26. package/tests/automation/data/testproj_dotnet/Pulumi.yaml +0 -3
  27. package/tests/automation/data/testproj_dotnet/TestProj.csproj +0 -12
  28. package/tests/automation/data/yaml/Pulumi.dev.yaml +0 -5
  29. package/tests/automation/data/yaml/Pulumi.yaml +0 -3
  30. package/tests/automation/data/yml/Pulumi.dev.yml +0 -5
  31. package/tests/automation/data/yml/Pulumi.yml +0 -3
  32. package/tests/automation/localWorkspace.spec.d.ts +0 -1
  33. package/tests/automation/localWorkspace.spec.js +0 -1325
  34. package/tests/automation/localWorkspace.spec.js.map +0 -1
  35. package/tests/automation/remoteWorkspace.spec.d.ts +0 -1
  36. package/tests/automation/remoteWorkspace.spec.js +0 -460
  37. package/tests/automation/remoteWorkspace.spec.js.map +0 -1
  38. package/tests/automation/util.d.ts +0 -1
  39. package/tests/automation/util.js +0 -31
  40. package/tests/automation/util.js.map +0 -1
  41. package/tests/config.spec.d.ts +0 -1
  42. package/tests/config.spec.js +0 -177
  43. package/tests/config.spec.js.map +0 -1
  44. package/tests/constants.d.ts +0 -1
  45. package/tests/constants.js +0 -18
  46. package/tests/constants.js.map +0 -1
  47. package/tests/init.spec.d.ts +0 -1
  48. package/tests/init.spec.js +0 -18
  49. package/tests/init.spec.js.map +0 -1
  50. package/tests/iterable.spec.d.ts +0 -1
  51. package/tests/iterable.spec.js +0 -60
  52. package/tests/iterable.spec.js.map +0 -1
  53. package/tests/options.spec.d.ts +0 -1
  54. package/tests/options.spec.js +0 -233
  55. package/tests/options.spec.js.map +0 -1
  56. package/tests/output.spec.d.ts +0 -1
  57. package/tests/output.spec.js +0 -809
  58. package/tests/output.spec.js.map +0 -1
  59. package/tests/provider.spec.d.ts +0 -1
  60. package/tests/provider.spec.js +0 -524
  61. package/tests/provider.spec.js.map +0 -1
  62. package/tests/resource.spec.d.ts +0 -1
  63. package/tests/resource.spec.js +0 -275
  64. package/tests/resource.spec.js.map +0 -1
  65. package/tests/runtime/asyncIterableUtil.spec.d.ts +0 -1
  66. package/tests/runtime/asyncIterableUtil.spec.js +0 -115
  67. package/tests/runtime/asyncIterableUtil.spec.js.map +0 -1
  68. package/tests/runtime/closure-integration-tests.d.ts +0 -1
  69. package/tests/runtime/closure-integration-tests.js +0 -120
  70. package/tests/runtime/closure-integration-tests.js.map +0 -1
  71. package/tests/runtime/findWorkspaceRoot.spec.d.ts +0 -1
  72. package/tests/runtime/findWorkspaceRoot.spec.js +0 -62
  73. package/tests/runtime/findWorkspaceRoot.spec.js.map +0 -1
  74. package/tests/runtime/install-package-tests.d.ts +0 -1
  75. package/tests/runtime/install-package-tests.js +0 -230
  76. package/tests/runtime/install-package-tests.js.map +0 -1
  77. package/tests/runtime/langhost/cases/000.empty/index.js +0 -1
  78. package/tests/runtime/langhost/cases/001.one_resource/index.js +0 -11
  79. package/tests/runtime/langhost/cases/002.ten_resources/index.js +0 -13
  80. package/tests/runtime/langhost/cases/003.one_complex_resource/index.js +0 -77
  81. package/tests/runtime/langhost/cases/004.ten_complex_resources/index.js +0 -38
  82. package/tests/runtime/langhost/cases/004.ten_complex_resources/resource.js +0 -30
  83. package/tests/runtime/langhost/cases/005.resource_thens/index.js +0 -72
  84. package/tests/runtime/langhost/cases/006.asset/index.js +0 -13
  85. package/tests/runtime/langhost/cases/006.asset/testdata.txt +0 -4
  86. package/tests/runtime/langhost/cases/007.promises_io/index.js +0 -25
  87. package/tests/runtime/langhost/cases/007.promises_io/testdata.txt +0 -4
  88. package/tests/runtime/langhost/cases/008.ten_depends_on_resources/index.js +0 -46
  89. package/tests/runtime/langhost/cases/009.invoke/index.js +0 -25
  90. package/tests/runtime/langhost/cases/010.runtime_settings/index.js +0 -22
  91. package/tests/runtime/langhost/cases/011.unhandled_error/index.js +0 -1
  92. package/tests/runtime/langhost/cases/012.assets_archive/index.js +0 -25
  93. package/tests/runtime/langhost/cases/013.unhandled_promise_rejection/index.js +0 -3
  94. package/tests/runtime/langhost/cases/014.read_resource/index.js +0 -19
  95. package/tests/runtime/langhost/cases/015.runtime_sxs/index.js +0 -100
  96. package/tests/runtime/langhost/cases/016.promise_leak/index.js +0 -3
  97. package/tests/runtime/langhost/cases/017.parent_defaults/index.js +0 -89
  98. package/tests/runtime/langhost/cases/018.logging/index.js +0 -15
  99. package/tests/runtime/langhost/cases/019.stack_exports/index.js +0 -15
  100. package/tests/runtime/langhost/cases/020.property_dependencies/index.js +0 -39
  101. package/tests/runtime/langhost/cases/021.parent_child_dependencies/index.js +0 -15
  102. package/tests/runtime/langhost/cases/022.parent_child_dependencies_2/index.js +0 -16
  103. package/tests/runtime/langhost/cases/023.parent_child_dependencies_3/index.js +0 -28
  104. package/tests/runtime/langhost/cases/024.parent_child_dependencies_4/index.js +0 -22
  105. package/tests/runtime/langhost/cases/025.parent_child_dependencies_5/index.js +0 -24
  106. package/tests/runtime/langhost/cases/026.parent_child_dependencies_6/index.js +0 -29
  107. package/tests/runtime/langhost/cases/027.parent_child_dependencies_7/index.js +0 -36
  108. package/tests/runtime/langhost/cases/028.parent_child_dependencies_8/index.js +0 -28
  109. package/tests/runtime/langhost/cases/029.parent_child_dependencies_9/index.js +0 -23
  110. package/tests/runtime/langhost/cases/030.import_resource/index.js +0 -11
  111. package/tests/runtime/langhost/cases/040.run_error/index.js +0 -3
  112. package/tests/runtime/langhost/cases/041.component_opt_single_provider/index.js +0 -89
  113. package/tests/runtime/langhost/cases/042.component_opt_providers_array/index.js +0 -89
  114. package/tests/runtime/langhost/cases/043.depends_on_non_resource/index.js +0 -11
  115. package/tests/runtime/langhost/cases/044.versions/index.js +0 -22
  116. package/tests/runtime/langhost/cases/045.ignore_changes/index.js +0 -11
  117. package/tests/runtime/langhost/cases/046.recursive_stack_exports/index.js +0 -19
  118. package/tests/runtime/langhost/cases/047.exported_function/index.js +0 -13
  119. package/tests/runtime/langhost/cases/048.exported_promise_function/index.js +0 -13
  120. package/tests/runtime/langhost/cases/049.exported_async_function/index.js +0 -13
  121. package/tests/runtime/langhost/cases/050.resource_creation_in_function/index.js +0 -11
  122. package/tests/runtime/langhost/cases/051.resource_creation_in_function_with_result/index.js +0 -12
  123. package/tests/runtime/langhost/cases/052.resource_creation_in_async_function_with_result/index.js +0 -12
  124. package/tests/runtime/langhost/cases/060.provider_invokes/index.js +0 -26
  125. package/tests/runtime/langhost/cases/061.provider_in_parent_invokes/index.js +0 -33
  126. package/tests/runtime/langhost/cases/062.providerref_invokes/index.js +0 -33
  127. package/tests/runtime/langhost/cases/063.providerref_in_parent_invokes/index.js +0 -41
  128. package/tests/runtime/langhost/cases/064.async_components/index.js +0 -44
  129. package/tests/runtime/langhost/cases/065.large_resource/index.js +0 -17
  130. package/tests/runtime/langhost/cases/066.replace_on_changes/index.js +0 -11
  131. package/tests/runtime/langhost/cases/067.native_es_module/index.js +0 -11
  132. package/tests/runtime/langhost/cases/067.native_es_module/package.json +0 -1
  133. package/tests/runtime/langhost/cases/068.remote_component_providers/index.js +0 -34
  134. package/tests/runtime/langhost/cases/068.remote_component_providers/package.json +0 -3
  135. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.d.ts +0 -1
  136. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.js +0 -11
  137. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.js.map +0 -1
  138. package/tests/runtime/langhost/cases/069.ambiguous_entrypoints/index.ts +0 -23
  139. package/tests/runtime/langhost/cases/070.unusual_alias_names/index.js +0 -26
  140. package/tests/runtime/langhost/cases/071.large_alias_counts/index.js +0 -22
  141. package/tests/runtime/langhost/cases/072.large_alias_lineage_chains/index.js +0 -55
  142. package/tests/runtime/langhost/cases/073.component_dependencies/index.js +0 -28
  143. package/tests/runtime/langhost/cases/074.source_position/index.js +0 -17
  144. package/tests/runtime/langhost/run.spec.d.ts +0 -1
  145. package/tests/runtime/langhost/run.spec.js +0 -1685
  146. package/tests/runtime/langhost/run.spec.js.map +0 -1
  147. package/tests/runtime/pack.d.ts +0 -1
  148. package/tests/runtime/pack.js +0 -56
  149. package/tests/runtime/pack.js.map +0 -1
  150. package/tests/runtime/props.spec.d.ts +0 -1
  151. package/tests/runtime/props.spec.js +0 -387
  152. package/tests/runtime/props.spec.js.map +0 -1
  153. package/tests/runtime/registrations.spec.d.ts +0 -1
  154. package/tests/runtime/registrations.spec.js +0 -139
  155. package/tests/runtime/registrations.spec.js.map +0 -1
  156. package/tests/runtime/rpc.spec.d.ts +0 -1
  157. package/tests/runtime/rpc.spec.js +0 -79
  158. package/tests/runtime/rpc.spec.js.map +0 -1
  159. package/tests/runtime/settings.spec.d.ts +0 -1
  160. package/tests/runtime/settings.spec.js +0 -57
  161. package/tests/runtime/settings.spec.js.map +0 -1
  162. package/tests/runtime/testdata/nested/project/index.d.ts +0 -0
  163. package/tests/runtime/testdata/nested/project/index.js +0 -16
  164. package/tests/runtime/testdata/nested/project/index.js.map +0 -1
  165. package/tests/stackReference.spec.d.ts +0 -1
  166. package/tests/stackReference.spec.js +0 -86
  167. package/tests/stackReference.spec.js.map +0 -1
  168. package/tests/unwrap.spec.d.ts +0 -1
  169. package/tests/unwrap.spec.js +0 -254
  170. package/tests/unwrap.spec.js.map +0 -1
  171. package/tests/util.d.ts +0 -1
  172. package/tests/util.js +0 -71
  173. package/tests/util.js.map +0 -1
  174. package/tests_with_mocks/mocks.spec.d.ts +0 -1
  175. package/tests_with_mocks/mocks.spec.js +0 -182
  176. package/tests_with_mocks/mocks.spec.js.map +0 -1
@@ -1,809 +0,0 @@
1
- "use strict";
2
- // Copyright 2016-2018, Pulumi Corporation.
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
28
- result["default"] = mod;
29
- return result;
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- /* eslint-disable */
33
- const assert = __importStar(require("assert"));
34
- const output_1 = require("../output");
35
- const runtime = __importStar(require("../runtime"));
36
- // This ensures that the optionality of 'x' and 'y' are preserved when describing an Output<Widget>.
37
- // Subtle changes in the definitions of Lifted<T> can make TS think these are required, which can
38
- // break downstream consumers.
39
- function mustCompile() {
40
- return output_1.output({
41
- type: "foo",
42
- properties: {
43
- whatever: 1,
44
- },
45
- });
46
- }
47
- // mockOutput returns a value that looks like an Output, but allows for greater control over its behavior. This can be
48
- // used to simulate outputs from downlevel SDKs.
49
- function mockOutput(isKnown, value) {
50
- isKnown = isKnown instanceof Promise ? isKnown : Promise.resolve(isKnown);
51
- value = value instanceof Promise ? value : Promise.resolve(value);
52
- return {
53
- __pulumiOutput: true,
54
- isKnown: isKnown,
55
- isSecret: Promise.resolve(false),
56
- promise: () => value,
57
- resources: () => new Set(),
58
- apply(callback) {
59
- return mockOutput(isKnown, value.then((v) => __awaiter(this, void 0, void 0, function* () {
60
- if (!isKnown) {
61
- return undefined;
62
- }
63
- return callback(v);
64
- })));
65
- },
66
- };
67
- }
68
- describe("output", () => {
69
- it("propagates true isKnown bit from inner Output", () => __awaiter(void 0, void 0, void 0, function* () {
70
- runtime._setIsDryRun(true);
71
- const output1 = new output_1.Output(new Set(), Promise.resolve("outer"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
72
- const output2 = output1.apply((v) => new output_1.Output(new Set(), Promise.resolve("inner"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set())));
73
- const isKnown = yield output2.isKnown;
74
- assert.strictEqual(isKnown, true);
75
- const value = yield output2.promise();
76
- assert.strictEqual(value, "inner");
77
- }));
78
- it("propagates false isKnown bit from inner Output", () => __awaiter(void 0, void 0, void 0, function* () {
79
- runtime._setIsDryRun(true);
80
- const output1 = new output_1.Output(new Set(), Promise.resolve("outer"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
81
- const output2 = output1.apply((v) => new output_1.Output(new Set(), Promise.resolve("inner"), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set())));
82
- const isKnown = yield output2.isKnown;
83
- assert.strictEqual(isKnown, false);
84
- const value = yield output2.promise();
85
- assert.strictEqual(value, "inner");
86
- }));
87
- it("can not await if isKnown is a rejected promise.", () => __awaiter(void 0, void 0, void 0, function* () {
88
- runtime._setIsDryRun(true);
89
- const output1 = new output_1.Output(new Set(), Promise.resolve("outer"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
90
- const output2 = output1.apply((v) => new output_1.Output(new Set(), Promise.resolve("inner"), Promise.reject(new Error("foo")), Promise.resolve(false), Promise.resolve(new Set())));
91
- try {
92
- const isKnown = yield output2.isKnown;
93
- assert.fail("Should not reach here");
94
- }
95
- catch (err) { }
96
- try {
97
- const value = yield output2.promise();
98
- assert.fail("Should not reach here");
99
- }
100
- catch (err) { }
101
- }));
102
- it("propagates true isSecret bit from inner Output", () => __awaiter(void 0, void 0, void 0, function* () {
103
- runtime._setIsDryRun(true);
104
- const output1 = new output_1.Output(new Set(), Promise.resolve("outer"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
105
- const output2 = output1.apply((v) => new output_1.Output(new Set(), Promise.resolve("inner"), Promise.resolve(true), Promise.resolve(true), Promise.resolve(new Set())));
106
- const isSecret = yield output2.isSecret;
107
- assert.strictEqual(isSecret, true);
108
- const value = yield output2.promise();
109
- assert.strictEqual(value, "inner");
110
- }));
111
- it("retains true isSecret bit from outer Output", () => __awaiter(void 0, void 0, void 0, function* () {
112
- runtime._setIsDryRun(true);
113
- const output1 = new output_1.Output(new Set(), Promise.resolve("outer"), Promise.resolve(true), Promise.resolve(true), Promise.resolve(new Set()));
114
- const output2 = output1.apply((v) => new output_1.Output(new Set(), Promise.resolve("inner"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set())));
115
- const isSecret = yield output2.isSecret;
116
- assert.strictEqual(isSecret, true);
117
- const value = yield output2.promise();
118
- assert.strictEqual(value, "inner");
119
- }));
120
- describe("apply", () => {
121
- function createOutput(val, isKnown, isSecret = false) {
122
- return new output_1.Output(new Set(), Promise.resolve(val), Promise.resolve(isKnown), Promise.resolve(isSecret), Promise.resolve(new Set()));
123
- }
124
- it("can run on known value during preview", () => __awaiter(void 0, void 0, void 0, function* () {
125
- runtime._setIsDryRun(true);
126
- const out = createOutput(0, true);
127
- const r = out.apply((v) => v + 1);
128
- assert.strictEqual(yield r.isKnown, true);
129
- assert.strictEqual(yield r.promise(), 1);
130
- }));
131
- it("can run on known awaitable value during preview", () => __awaiter(void 0, void 0, void 0, function* () {
132
- runtime._setIsDryRun(true);
133
- const out = createOutput(0, true);
134
- const r = out.apply((v) => Promise.resolve("inner"));
135
- assert.strictEqual(yield r.isKnown, true);
136
- assert.strictEqual(yield r.promise(), "inner");
137
- }));
138
- it("can run on known known output value during preview", () => __awaiter(void 0, void 0, void 0, function* () {
139
- runtime._setIsDryRun(true);
140
- const out = createOutput(0, true);
141
- const r = out.apply((v) => createOutput("inner", true));
142
- assert.strictEqual(yield r.isKnown, true);
143
- assert.strictEqual(yield r.promise(), "inner");
144
- }));
145
- it("can run on known unknown output value during preview", () => __awaiter(void 0, void 0, void 0, function* () {
146
- runtime._setIsDryRun(true);
147
- const out = createOutput(0, true);
148
- const r = out.apply((v) => createOutput("inner", false));
149
- assert.strictEqual(yield r.isKnown, false);
150
- assert.strictEqual(yield r.promise(), "inner");
151
- }));
152
- it("produces unknown default on unknown during preview", () => __awaiter(void 0, void 0, void 0, function* () {
153
- runtime._setIsDryRun(true);
154
- const out = createOutput(0, false);
155
- const r = out.apply((v) => v + 1);
156
- assert.strictEqual(yield r.isKnown, false);
157
- assert.strictEqual(yield r.promise(), undefined);
158
- }));
159
- it("produces unknown default on unknown awaitable during preview", () => __awaiter(void 0, void 0, void 0, function* () {
160
- runtime._setIsDryRun(true);
161
- const out = createOutput(0, false);
162
- const r = out.apply((v) => Promise.resolve("inner"));
163
- assert.strictEqual(yield r.isKnown, false);
164
- assert.strictEqual(yield r.promise(), undefined);
165
- }));
166
- it("produces unknown default on unknown known output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
167
- runtime._setIsDryRun(true);
168
- const out = createOutput(0, false);
169
- const r = out.apply((v) => createOutput("inner", true));
170
- assert.strictEqual(yield r.isKnown, false);
171
- assert.strictEqual(yield r.promise(), undefined);
172
- }));
173
- it("produces unknown default on unknown unknown output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
174
- runtime._setIsDryRun(true);
175
- const out = createOutput(0, false);
176
- const r = out.apply((v) => createOutput("inner", false));
177
- assert.strictEqual(yield r.isKnown, false);
178
- assert.strictEqual(yield r.promise(), undefined);
179
- }));
180
- it("preserves secret on known during preview", () => __awaiter(void 0, void 0, void 0, function* () {
181
- runtime._setIsDryRun(true);
182
- const out = createOutput(0, true, true);
183
- const r = out.apply((v) => v + 1);
184
- assert.strictEqual(yield r.isKnown, true);
185
- assert.strictEqual(yield r.isSecret, true);
186
- assert.strictEqual(yield r.promise(), 1);
187
- }));
188
- it("preserves secret on known awaitable during preview", () => __awaiter(void 0, void 0, void 0, function* () {
189
- runtime._setIsDryRun(true);
190
- const out = createOutput(0, true, true);
191
- const r = out.apply((v) => Promise.resolve("inner"));
192
- assert.strictEqual(yield r.isKnown, true);
193
- assert.strictEqual(yield r.isSecret, true);
194
- assert.strictEqual(yield r.promise(), "inner");
195
- }));
196
- it("preserves secret on known known output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
197
- runtime._setIsDryRun(true);
198
- const out = createOutput(0, true, true);
199
- const r = out.apply((v) => createOutput("inner", true));
200
- assert.strictEqual(yield r.isKnown, true);
201
- assert.strictEqual(yield r.isSecret, true);
202
- assert.strictEqual(yield r.promise(), "inner");
203
- }));
204
- it("preserves secret on known unknown output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
205
- runtime._setIsDryRun(true);
206
- const out = createOutput(0, true, true);
207
- const r = out.apply((v) => createOutput("inner", false));
208
- assert.strictEqual(yield r.isKnown, false);
209
- assert.strictEqual(yield r.isSecret, true);
210
- assert.strictEqual(yield r.promise(), "inner");
211
- }));
212
- it("preserves secret on unknown during preview", () => __awaiter(void 0, void 0, void 0, function* () {
213
- runtime._setIsDryRun(true);
214
- const out = createOutput(0, false, true);
215
- const r = out.apply((v) => v + 1);
216
- assert.strictEqual(yield r.isKnown, false);
217
- assert.strictEqual(yield r.isSecret, true);
218
- assert.strictEqual(yield r.promise(), undefined);
219
- }));
220
- it("preserves secret on unknown awaitable during preview", () => __awaiter(void 0, void 0, void 0, function* () {
221
- runtime._setIsDryRun(true);
222
- const out = createOutput(0, false, true);
223
- const r = out.apply((v) => Promise.resolve("inner"));
224
- assert.strictEqual(yield r.isKnown, false);
225
- assert.strictEqual(yield r.isSecret, true);
226
- assert.strictEqual(yield r.promise(), undefined);
227
- }));
228
- it("preserves secret on unknown known output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
229
- runtime._setIsDryRun(true);
230
- const out = createOutput(0, false, true);
231
- const r = out.apply((v) => createOutput("inner", true));
232
- assert.strictEqual(yield r.isKnown, false);
233
- assert.strictEqual(yield r.isSecret, true);
234
- assert.strictEqual(yield r.promise(), undefined);
235
- }));
236
- it("preserves secret on unknown unknown output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
237
- runtime._setIsDryRun(true);
238
- const out = createOutput(0, false, true);
239
- const r = out.apply((v) => createOutput("inner", false));
240
- assert.strictEqual(yield r.isKnown, false);
241
- assert.strictEqual(yield r.isSecret, true);
242
- assert.strictEqual(yield r.promise(), undefined);
243
- }));
244
- it("propagates secret on known known output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
245
- runtime._setIsDryRun(true);
246
- const out = createOutput(0, true);
247
- const r = out.apply((v) => createOutput("inner", true, true));
248
- assert.strictEqual(yield r.isKnown, true);
249
- assert.strictEqual(yield r.isSecret, true);
250
- assert.strictEqual(yield r.promise(), "inner");
251
- }));
252
- it("propagates secret on known unknown output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
253
- runtime._setIsDryRun(true);
254
- const out = createOutput(0, true);
255
- const r = out.apply((v) => createOutput("inner", false, true));
256
- assert.strictEqual(yield r.isKnown, false);
257
- assert.strictEqual(yield r.isSecret, true);
258
- assert.strictEqual(yield r.promise(), "inner");
259
- }));
260
- it("does not propagate secret on unknown known output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
261
- runtime._setIsDryRun(true);
262
- const out = createOutput(0, false);
263
- const r = out.apply((v) => createOutput("inner", true, true));
264
- assert.strictEqual(yield r.isKnown, false);
265
- assert.strictEqual(yield r.isSecret, false);
266
- assert.strictEqual(yield r.promise(), undefined);
267
- }));
268
- it("does not propagate secret on unknown unknown output during preview", () => __awaiter(void 0, void 0, void 0, function* () {
269
- runtime._setIsDryRun(true);
270
- const out = createOutput(0, false);
271
- const r = out.apply((v) => createOutput("inner", false, true));
272
- assert.strictEqual(yield r.isKnown, false);
273
- assert.strictEqual(yield r.isSecret, false);
274
- assert.strictEqual(yield r.promise(), undefined);
275
- }));
276
- it("can run on known value", () => __awaiter(void 0, void 0, void 0, function* () {
277
- runtime._setIsDryRun(false);
278
- const out = createOutput(0, true);
279
- const r = out.apply((v) => v + 1);
280
- assert.strictEqual(yield r.isKnown, true);
281
- assert.strictEqual(yield r.promise(), 1);
282
- }));
283
- it("can run on known awaitable value", () => __awaiter(void 0, void 0, void 0, function* () {
284
- runtime._setIsDryRun(false);
285
- const out = createOutput(0, true);
286
- const r = out.apply((v) => Promise.resolve("inner"));
287
- assert.strictEqual(yield r.isKnown, true);
288
- assert.strictEqual(yield r.promise(), "inner");
289
- }));
290
- it("can run on known known output value", () => __awaiter(void 0, void 0, void 0, function* () {
291
- runtime._setIsDryRun(false);
292
- const out = createOutput(0, true);
293
- const r = out.apply((v) => createOutput("inner", true));
294
- assert.strictEqual(yield r.isKnown, true);
295
- assert.strictEqual(yield r.promise(), "inner");
296
- }));
297
- it("can run on unknown known output value", () => __awaiter(void 0, void 0, void 0, function* () {
298
- runtime._setIsDryRun(false);
299
- const out = createOutput(0, true);
300
- const r = out.apply((v) => createOutput("inner", false));
301
- assert.strictEqual(yield r.isKnown, false);
302
- assert.strictEqual(yield r.promise(), "inner");
303
- }));
304
- it("produces unknown on unknown", () => __awaiter(void 0, void 0, void 0, function* () {
305
- runtime._setIsDryRun(false);
306
- const out = createOutput(0, false);
307
- const r = out.apply((v) => v + 1);
308
- assert.strictEqual(yield r.isKnown, false);
309
- }));
310
- it("produces unknown on unknown awaitable", () => __awaiter(void 0, void 0, void 0, function* () {
311
- runtime._setIsDryRun(false);
312
- const out = createOutput(0, false);
313
- const r = out.apply((v) => Promise.resolve("inner"));
314
- assert.strictEqual(yield r.isKnown, false);
315
- }));
316
- it("produces unknown on unknown known output", () => __awaiter(void 0, void 0, void 0, function* () {
317
- runtime._setIsDryRun(false);
318
- const out = createOutput(0, false);
319
- const r = out.apply((v) => createOutput("inner", true));
320
- assert.strictEqual(yield r.isKnown, false);
321
- }));
322
- it("produces unknown on unknown unknown output", () => __awaiter(void 0, void 0, void 0, function* () {
323
- runtime._setIsDryRun(false);
324
- const out = createOutput(0, false);
325
- const r = out.apply((v) => createOutput("inner", false));
326
- assert.strictEqual(yield r.isKnown, false);
327
- }));
328
- it("preserves secret on known", () => __awaiter(void 0, void 0, void 0, function* () {
329
- runtime._setIsDryRun(false);
330
- const out = createOutput(0, true, true);
331
- const r = out.apply((v) => v + 1);
332
- assert.strictEqual(yield r.isKnown, true);
333
- assert.strictEqual(yield r.isSecret, true);
334
- assert.strictEqual(yield r.promise(), 1);
335
- }));
336
- it("preserves secret on known awaitable", () => __awaiter(void 0, void 0, void 0, function* () {
337
- runtime._setIsDryRun(false);
338
- const out = createOutput(0, true, true);
339
- const r = out.apply((v) => Promise.resolve("inner"));
340
- assert.strictEqual(yield r.isKnown, true);
341
- assert.strictEqual(yield r.isSecret, true);
342
- assert.strictEqual(yield r.promise(), "inner");
343
- }));
344
- it("preserves secret on known known output", () => __awaiter(void 0, void 0, void 0, function* () {
345
- runtime._setIsDryRun(false);
346
- const out = createOutput(0, true, true);
347
- const r = out.apply((v) => createOutput("inner", true));
348
- assert.strictEqual(yield r.isKnown, true);
349
- assert.strictEqual(yield r.isSecret, true);
350
- assert.strictEqual(yield r.promise(), "inner");
351
- }));
352
- it("preserves secret on known known output", () => __awaiter(void 0, void 0, void 0, function* () {
353
- runtime._setIsDryRun(false);
354
- const out = createOutput(0, true, true);
355
- const r = out.apply((v) => createOutput("inner", false));
356
- assert.strictEqual(yield r.isKnown, false);
357
- assert.strictEqual(yield r.isSecret, true);
358
- assert.strictEqual(yield r.promise(), "inner");
359
- }));
360
- it("preserves secret on unknown", () => __awaiter(void 0, void 0, void 0, function* () {
361
- runtime._setIsDryRun(false);
362
- const out = createOutput(0, false, true);
363
- const r = out.apply((v) => v + 1);
364
- assert.strictEqual(yield r.isKnown, false);
365
- assert.strictEqual(yield r.isSecret, true);
366
- }));
367
- it("preserves secret on unknown awaitable", () => __awaiter(void 0, void 0, void 0, function* () {
368
- runtime._setIsDryRun(false);
369
- const out = createOutput(0, false, true);
370
- const r = out.apply((v) => Promise.resolve("inner"));
371
- assert.strictEqual(yield r.isKnown, false);
372
- assert.strictEqual(yield r.isSecret, true);
373
- }));
374
- it("preserves secret on unknown known output", () => __awaiter(void 0, void 0, void 0, function* () {
375
- runtime._setIsDryRun(false);
376
- const out = createOutput(0, false, true);
377
- const r = out.apply((v) => createOutput("inner", true));
378
- assert.strictEqual(yield r.isKnown, false);
379
- assert.strictEqual(yield r.isSecret, true);
380
- }));
381
- it("preserves secret on unknown known output", () => __awaiter(void 0, void 0, void 0, function* () {
382
- runtime._setIsDryRun(false);
383
- const out = createOutput(0, false, true);
384
- const r = out.apply((v) => createOutput("inner", false));
385
- assert.strictEqual(yield r.isKnown, false);
386
- assert.strictEqual(yield r.isSecret, true);
387
- }));
388
- it("propagates secret on known known output", () => __awaiter(void 0, void 0, void 0, function* () {
389
- runtime._setIsDryRun(false);
390
- const out = createOutput(0, true);
391
- const r = out.apply((v) => createOutput("inner", true, true));
392
- assert.strictEqual(yield r.isKnown, true);
393
- assert.strictEqual(yield r.isSecret, true);
394
- }));
395
- it("propagates secret on known unknown output", () => __awaiter(void 0, void 0, void 0, function* () {
396
- runtime._setIsDryRun(false);
397
- const out = createOutput(0, true);
398
- const r = out.apply((v) => createOutput("inner", false, true));
399
- assert.strictEqual(yield r.isKnown, false);
400
- assert.strictEqual(yield r.isSecret, true);
401
- }));
402
- });
403
- describe("isKnown", () => {
404
- function or(output1, output2) {
405
- const val1 = output1.promise();
406
- const val2 = output2.promise();
407
- return new output_1.Output(new Set([...output1.resources(), ...output2.resources()]), Promise.all([val1, val2]).then(([val1, val2]) => val1 || val2), Promise.all([val1, output1.isKnown, output2.isKnown]).then(([val1, isKnown1, isKnown2]) => val1 ? isKnown1 : isKnown2), Promise.all([val1, output1.isSecret, output2.isSecret]).then(([val1, isSecret1, isSecret2]) => val1 ? isSecret1 : isSecret2), Promise.all([output1.allResources(), output2.allResources()]).then(([r1, r2]) => new Set([...r1, ...r2])));
408
- }
409
- it("choose between known and known output, non-secret", () => __awaiter(void 0, void 0, void 0, function* () {
410
- runtime._setIsDryRun(true);
411
- const o1 = new output_1.Output(new Set(), Promise.resolve("foo"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
412
- const o2 = new output_1.Output(new Set(), Promise.resolve("bar"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
413
- const result = or(o1, o2);
414
- const isKnown = yield result.isKnown;
415
- assert.strictEqual(isKnown, true);
416
- const value = yield result.promise();
417
- assert.strictEqual(value, "foo");
418
- const secret = yield result.isSecret;
419
- assert.strictEqual(secret, false);
420
- }));
421
- it("choose between known and known output, secret", () => __awaiter(void 0, void 0, void 0, function* () {
422
- runtime._setIsDryRun(true);
423
- const o1 = new output_1.Output(new Set(), Promise.resolve("foo"), Promise.resolve(true), Promise.resolve(true), Promise.resolve(new Set()));
424
- const o2 = new output_1.Output(new Set(), Promise.resolve("bar"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
425
- const result = or(o1, o2);
426
- const isKnown = yield result.isKnown;
427
- assert.strictEqual(isKnown, true);
428
- const value = yield result.promise();
429
- assert.strictEqual(value, "foo");
430
- const secret = yield result.isSecret;
431
- assert.strictEqual(secret, true);
432
- }));
433
- it("choose between known and unknown output, non-secret", () => __awaiter(void 0, void 0, void 0, function* () {
434
- runtime._setIsDryRun(true);
435
- const o1 = new output_1.Output(new Set(), Promise.resolve("foo"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
436
- const o2 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
437
- const result = or(o1, o2);
438
- const isKnown = yield result.isKnown;
439
- assert.strictEqual(isKnown, true);
440
- const value = yield result.promise();
441
- assert.strictEqual(value, "foo");
442
- const secret = yield result.isSecret;
443
- assert.strictEqual(secret, false);
444
- }));
445
- it("choose between known and unknown output, secret", () => __awaiter(void 0, void 0, void 0, function* () {
446
- runtime._setIsDryRun(true);
447
- const o1 = new output_1.Output(new Set(), Promise.resolve("foo"), Promise.resolve(true), Promise.resolve(true), Promise.resolve(new Set()));
448
- const o2 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
449
- const result = or(o1, o2);
450
- const isKnown = yield result.isKnown;
451
- assert.strictEqual(isKnown, true);
452
- const value = yield result.promise();
453
- assert.strictEqual(value, "foo");
454
- const secret = yield result.isSecret;
455
- assert.strictEqual(secret, true);
456
- }));
457
- it("choose between unknown and known output, non-secret", () => __awaiter(void 0, void 0, void 0, function* () {
458
- runtime._setIsDryRun(true);
459
- const o1 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
460
- const o2 = new output_1.Output(new Set(), Promise.resolve("bar"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
461
- const result = or(o1, o2);
462
- const isKnown = yield result.isKnown;
463
- assert.strictEqual(isKnown, true);
464
- const value = yield result.promise();
465
- assert.strictEqual(value, "bar");
466
- const secret = yield result.isSecret;
467
- assert.strictEqual(secret, false);
468
- }));
469
- it("choose between unknown and known output, secret", () => __awaiter(void 0, void 0, void 0, function* () {
470
- runtime._setIsDryRun(true);
471
- const o1 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
472
- const o2 = new output_1.Output(new Set(), Promise.resolve("bar"), Promise.resolve(true), Promise.resolve(true), Promise.resolve(new Set()));
473
- const result = or(o1, o2);
474
- const isKnown = yield result.isKnown;
475
- assert.strictEqual(isKnown, true);
476
- const value = yield result.promise();
477
- assert.strictEqual(value, "bar");
478
- const secret = yield result.isSecret;
479
- assert.strictEqual(secret, true);
480
- }));
481
- it("choose between unknown and unknown output, non-secret", () => __awaiter(void 0, void 0, void 0, function* () {
482
- runtime._setIsDryRun(true);
483
- const o1 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
484
- const o2 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
485
- const result = or(o1, o2);
486
- const isKnown = yield result.isKnown;
487
- assert.strictEqual(isKnown, false);
488
- const value = yield result.promise();
489
- assert.strictEqual(value, undefined);
490
- const secret = yield result.isSecret;
491
- assert.strictEqual(secret, false);
492
- }));
493
- it("choose between unknown and unknown output, secret1", () => __awaiter(void 0, void 0, void 0, function* () {
494
- runtime._setIsDryRun(true);
495
- const o1 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(true), Promise.resolve(new Set()));
496
- const o2 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
497
- const result = or(o1, o2);
498
- const isKnown = yield result.isKnown;
499
- assert.strictEqual(isKnown, false);
500
- const value = yield result.promise();
501
- assert.strictEqual(value, undefined);
502
- const secret = yield result.isSecret;
503
- assert.strictEqual(secret, false);
504
- }));
505
- it("choose between unknown and unknown output, secret2", () => __awaiter(void 0, void 0, void 0, function* () {
506
- runtime._setIsDryRun(true);
507
- const o1 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set()));
508
- const o2 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(true), Promise.resolve(new Set()));
509
- const result = or(o1, o2);
510
- const isKnown = yield result.isKnown;
511
- assert.strictEqual(isKnown, false);
512
- const value = yield result.promise();
513
- assert.strictEqual(value, undefined);
514
- const secret = yield result.isSecret;
515
- assert.strictEqual(secret, true);
516
- }));
517
- it("choose between unknown and unknown output, secret3", () => __awaiter(void 0, void 0, void 0, function* () {
518
- runtime._setIsDryRun(true);
519
- const o1 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(true), Promise.resolve(new Set()));
520
- const o2 = new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(true), Promise.resolve(new Set()));
521
- const result = or(o1, o2);
522
- const isKnown = yield result.isKnown;
523
- assert.strictEqual(isKnown, false);
524
- const value = yield result.promise();
525
- assert.strictEqual(value, undefined);
526
- const secret = yield result.isSecret;
527
- assert.strictEqual(secret, true);
528
- }));
529
- it("is unknown if the value is or contains unknowns", () => __awaiter(void 0, void 0, void 0, function* () {
530
- runtime._setIsDryRun(true);
531
- const o1 = new output_1.Output(new Set(), Promise.resolve(output_1.unknown), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
532
- const o2 = new output_1.Output(new Set(), Promise.resolve(["foo", output_1.unknown]), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
533
- const o3 = new output_1.Output(new Set(), Promise.resolve({ foo: "foo", unknown: output_1.unknown }), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
534
- assert.strictEqual(yield o1.isKnown, false);
535
- assert.strictEqual(yield o2.isKnown, false);
536
- assert.strictEqual(yield o3.isKnown, false);
537
- }));
538
- it("is unknown if the result after apply is unknown or contains unknowns", () => __awaiter(void 0, void 0, void 0, function* () {
539
- runtime._setIsDryRun(true);
540
- const o1 = new output_1.Output(new Set(), Promise.resolve("foo"), Promise.resolve(true), Promise.resolve(false), Promise.resolve(new Set()));
541
- const r1 = o1.apply((v) => output_1.unknown);
542
- const r2 = o1.apply((v) => [v, output_1.unknown]);
543
- const r3 = o1.apply((v) => ({ v, unknown: output_1.unknown }));
544
- const r4 = o1.apply((v) => output_1.unknown).apply((v) => v, true);
545
- const r5 = o1.apply((v) => [v, output_1.unknown]).apply((v) => v, true);
546
- const r6 = o1.apply((v) => ({ v, unknown: output_1.unknown })).apply((v) => v, true);
547
- assert.strictEqual(yield r1.isKnown, false);
548
- assert.strictEqual(yield r2.isKnown, false);
549
- assert.strictEqual(yield r3.isKnown, false);
550
- assert.strictEqual(yield r4.isKnown, false);
551
- assert.strictEqual(yield r5.isKnown, false);
552
- assert.strictEqual(yield r6.isKnown, false);
553
- }));
554
- });
555
- describe("concat", () => {
556
- it("handles no args", () => __awaiter(void 0, void 0, void 0, function* () {
557
- const result = output_1.concat();
558
- assert.strictEqual(yield result.promise(), "");
559
- }));
560
- it("handles empty string arg", () => __awaiter(void 0, void 0, void 0, function* () {
561
- const result = output_1.concat("");
562
- assert.strictEqual(yield result.promise(), "");
563
- }));
564
- it("handles non-empty string arg", () => __awaiter(void 0, void 0, void 0, function* () {
565
- const result = output_1.concat("a");
566
- assert.strictEqual(yield result.promise(), "a");
567
- }));
568
- it("handles promise string arg", () => __awaiter(void 0, void 0, void 0, function* () {
569
- const result = output_1.concat(Promise.resolve("a"));
570
- assert.strictEqual(yield result.promise(), "a");
571
- }));
572
- it("handles output string arg", () => __awaiter(void 0, void 0, void 0, function* () {
573
- const result = output_1.concat(output_1.output("a"));
574
- assert.strictEqual(yield result.promise(), "a");
575
- }));
576
- it("handles multiple args", () => __awaiter(void 0, void 0, void 0, function* () {
577
- const result = output_1.concat("http://", output_1.output("a"), ":", 80);
578
- assert.strictEqual(yield result.promise(), "http://a:80");
579
- }));
580
- });
581
- describe("interpolate", () => {
582
- it("handles empty interpolation", () => __awaiter(void 0, void 0, void 0, function* () {
583
- const result = output_1.interpolate ``;
584
- assert.strictEqual(yield result.promise(), "");
585
- }));
586
- it("handles no placeholders arg", () => __awaiter(void 0, void 0, void 0, function* () {
587
- const result = output_1.interpolate `a`;
588
- assert.strictEqual(yield result.promise(), "a");
589
- }));
590
- it("handles string placeholders arg", () => __awaiter(void 0, void 0, void 0, function* () {
591
- const result = output_1.interpolate `${"a"}`;
592
- assert.strictEqual(yield result.promise(), "a");
593
- }));
594
- it("handles promise placeholders arg", () => __awaiter(void 0, void 0, void 0, function* () {
595
- const result = output_1.interpolate `${Promise.resolve("a")}`;
596
- assert.strictEqual(yield result.promise(), "a");
597
- }));
598
- it("handles output placeholders arg", () => __awaiter(void 0, void 0, void 0, function* () {
599
- const result = output_1.interpolate `${output_1.output("a")}`;
600
- assert.strictEqual(yield result.promise(), "a");
601
- }));
602
- it("handles multiple args", () => __awaiter(void 0, void 0, void 0, function* () {
603
- const result = output_1.interpolate `http://${output_1.output("a")}:${80}/`;
604
- assert.strictEqual(yield result.promise(), "http://a:80/");
605
- }));
606
- });
607
- describe("jsonStringify", () => {
608
- it("basic", () => __awaiter(void 0, void 0, void 0, function* () {
609
- const x = output_1.output([0, 1]);
610
- const result = output_1.jsonStringify(x);
611
- assert.strictEqual(yield result.promise(), "[0,1]");
612
- assert.strictEqual(yield result.isKnown, true);
613
- assert.strictEqual(yield result.isSecret, false);
614
- }));
615
- it("nested", () => __awaiter(void 0, void 0, void 0, function* () {
616
- const x = output_1.output([output_1.output(0), output_1.output(1)]);
617
- const result = output_1.jsonStringify(x);
618
- assert.strictEqual(yield result.promise(), "[0,1]");
619
- assert.strictEqual(yield result.isKnown, true);
620
- assert.strictEqual(yield result.isSecret, false);
621
- }));
622
- it("nested unknowns", () => __awaiter(void 0, void 0, void 0, function* () {
623
- const x = output_1.output([
624
- new output_1.Output(new Set(), Promise.resolve(undefined), Promise.resolve(false), Promise.resolve(false), Promise.resolve(new Set())),
625
- output_1.output(1),
626
- ]);
627
- const result = output_1.jsonStringify(x);
628
- assert.strictEqual(yield result.isKnown, false);
629
- assert.strictEqual(yield result.isSecret, false);
630
- }));
631
- it("nested secret", () => __awaiter(void 0, void 0, void 0, function* () {
632
- const x = output_1.output([
633
- new output_1.Output(new Set(), Promise.resolve(0), Promise.resolve(true), Promise.resolve(true), Promise.resolve(new Set())),
634
- output_1.output(1),
635
- ]);
636
- const result = output_1.jsonStringify(x);
637
- assert.strictEqual(yield result.promise(), "[0,1]");
638
- assert.strictEqual(yield result.isKnown, true);
639
- assert.strictEqual(yield result.isSecret, true);
640
- }));
641
- it("with options", () => __awaiter(void 0, void 0, void 0, function* () {
642
- const x = output_1.output([0, 1]);
643
- const result = output_1.jsonStringify(x, undefined, " ");
644
- assert.strictEqual(yield result.promise(), "[\n 0,\n 1\n]");
645
- assert.strictEqual(yield result.isKnown, true);
646
- assert.strictEqual(yield result.isSecret, false);
647
- }));
648
- it("nested dependencies", () => __awaiter(void 0, void 0, void 0, function* () {
649
- // Output's don't actually _look_ at the resources, they just need to keep a collection of them
650
- const mockResource = {};
651
- const mockResources = [mockResource];
652
- const x = output_1.output([
653
- new output_1.Output(new Set(mockResources), Promise.resolve(0), Promise.resolve(true), Promise.resolve(true), Promise.resolve(new Set())),
654
- output_1.output(1),
655
- ]);
656
- const result = output_1.jsonStringify(x);
657
- assert.strictEqual(yield result.promise(), "[0,1]");
658
- assert.strictEqual(yield result.isKnown, true);
659
- assert.strictEqual(yield result.isSecret, true);
660
- if (result.allResources === undefined) {
661
- assert.fail("Output.allResources was undefined");
662
- }
663
- const allResources = yield result.allResources();
664
- // We should have just the one mockResource in this set
665
- assert.strictEqual(allResources.size, 1);
666
- assert.ok(allResources.has(mockResource));
667
- }));
668
- });
669
- describe("jsonParse", () => {
670
- it("basic", () => __awaiter(void 0, void 0, void 0, function* () {
671
- const x = output_1.output("[0, 1]");
672
- const result = output_1.jsonParse(x);
673
- assert.deepStrictEqual(yield result.promise(), [0, 1]);
674
- assert.strictEqual(yield result.isKnown, true);
675
- assert.strictEqual(yield result.isSecret, false);
676
- }));
677
- it("with reviver", () => __awaiter(void 0, void 0, void 0, function* () {
678
- const reviver = (key, value) => {
679
- if (key === "bob") {
680
- return "goodbye";
681
- }
682
- return value;
683
- };
684
- const x = output_1.output('{"bob": "hello"}');
685
- const result = output_1.jsonParse(x, reviver);
686
- assert.deepStrictEqual(yield result.promise(), { bob: "goodbye" });
687
- assert.strictEqual(yield result.isKnown, true);
688
- assert.strictEqual(yield result.isSecret, false);
689
- }));
690
- });
691
- describe("secret operations", () => {
692
- it("ensure secret", () => __awaiter(void 0, void 0, void 0, function* () {
693
- const sec = output_1.secret("foo");
694
- assert.strictEqual(yield sec.isSecret, true);
695
- }));
696
- it("ensure that a secret can be unwrapped", () => __awaiter(void 0, void 0, void 0, function* () {
697
- const sec = output_1.secret("foo");
698
- assert.strictEqual(yield output_1.isSecret(sec), true);
699
- const unsec = output_1.unsecret(sec);
700
- assert.strictEqual(yield output_1.isSecret(unsec), false);
701
- assert.strictEqual(yield unsec.promise(), "foo");
702
- }));
703
- });
704
- describe("lifted operations", () => {
705
- it("lifts properties from inner object", () => __awaiter(void 0, void 0, void 0, function* () {
706
- const output1 = output_1.output({ a: 1, b: true, c: "str", d: [2], e: { f: 3 }, g: undefined, h: null });
707
- assert.strictEqual(yield output1.a.promise(), 1);
708
- assert.strictEqual(yield output1.b.promise(), true);
709
- assert.strictEqual(yield output1.c.promise(), "str");
710
- // Can lift both outer arrays as well as array accesses
711
- assert.deepStrictEqual(yield output1.d.promise(), [2]);
712
- assert.strictEqual(yield output1.d[0].promise(), 2);
713
- // Can lift nested objects as well as their properties.
714
- assert.deepStrictEqual(yield output1.e.promise(), { f: 3 });
715
- assert.strictEqual(yield output1.e.f.promise(), 3);
716
- assert.strictEqual(yield output1.g.promise(), undefined);
717
- assert.strictEqual(yield output1.h.promise(), null);
718
- // Unspecified things can be lifted, but produce 'undefined'.
719
- assert.notEqual(output1.z, undefined);
720
- assert.strictEqual(yield output1.z.promise(), undefined);
721
- }));
722
- it("prefers Output members over lifted members", () => __awaiter(void 0, void 0, void 0, function* () {
723
- const output1 = output_1.output({ apply: 1, promise: 2 });
724
- assert.ok(output1.apply instanceof Function);
725
- assert.ok(output1.isKnown instanceof Promise);
726
- }));
727
- it("does not lift symbols", () => __awaiter(void 0, void 0, void 0, function* () {
728
- const output1 = output_1.output({ apply: 1, promise: 2 });
729
- assert.strictEqual(output1[Symbol.toPrimitive], undefined);
730
- }));
731
- it("does not lift __ properties", () => __awaiter(void 0, void 0, void 0, function* () {
732
- const output1 = output_1.output({ a: 1, b: 2 });
733
- assert.strictEqual(output1.__pulumiResource, undefined);
734
- }));
735
- it("lifts properties from values with nested unknowns", () => __awaiter(void 0, void 0, void 0, function* () {
736
- runtime._setIsDryRun(true);
737
- const output1 = output_1.output({
738
- foo: "foo",
739
- bar: output_1.unknown,
740
- baz: Promise.resolve(output_1.unknown),
741
- qux: mockOutput(false, undefined),
742
- });
743
- assert.strictEqual(yield output1.isKnown, false);
744
- const result1 = output1.foo;
745
- assert.strictEqual(yield result1.isKnown, true);
746
- assert.strictEqual(yield result1.promise(/*withUnknowns*/ true), "foo");
747
- const result2 = output1.bar;
748
- assert.strictEqual(yield result2.isKnown, false);
749
- assert.strictEqual(yield result2.promise(/*withUnknowns*/ true), output_1.unknown);
750
- const result3 = output1.baz;
751
- assert.strictEqual(yield result3.isKnown, false);
752
- assert.strictEqual(yield result3.promise(/*withUnknowns*/ true), output_1.unknown);
753
- const result4 = output1.qux;
754
- assert.strictEqual(yield result4.isKnown, false);
755
- assert.strictEqual(yield result4.promise(/*withUnknowns*/ true), output_1.unknown);
756
- const result5 = output1.baz.qux;
757
- assert.strictEqual(yield result5.isKnown, false);
758
- assert.strictEqual(yield result5.promise(/*withUnknowns*/ true), output_1.unknown);
759
- const output2 = output_1.output(["foo", output_1.unknown, mockOutput(false, undefined)]);
760
- assert.strictEqual(yield output2.isKnown, false);
761
- const result6 = output2[0];
762
- assert.strictEqual(yield result6.isKnown, true);
763
- assert.strictEqual(yield result6.promise(/*withUnknowns*/ true), "foo");
764
- const result7 = output2[1];
765
- assert.strictEqual(yield result7.isKnown, false);
766
- assert.strictEqual(yield result7.promise(/*withUnknowns*/ true), output_1.unknown);
767
- const result8 = output2[2];
768
- assert.strictEqual(yield result8.isKnown, false);
769
- assert.strictEqual(yield result8.promise(/*withUnknowns*/ true), output_1.unknown);
770
- const output3 = output_1.all([output_1.unknown, mockOutput(false, undefined), output_1.output(["foo", output_1.unknown])]);
771
- assert.strictEqual(yield output3.isKnown, false);
772
- const result9 = output3[0];
773
- assert.strictEqual(yield result9.isKnown, false);
774
- assert.strictEqual(yield result9.promise(/*withUnknowns*/ true), output_1.unknown);
775
- const result10 = output3[1];
776
- assert.strictEqual(yield result10.isKnown, false);
777
- assert.strictEqual(yield result10.promise(/*withUnknowns*/ true), output_1.unknown);
778
- const result11 = output3[2];
779
- assert.strictEqual(yield result11.isKnown, false);
780
- const result12 = result11[0];
781
- assert.strictEqual(yield result12.isKnown, true);
782
- assert.strictEqual(yield result12.promise(/*withUnknowns*/ true), "foo");
783
- const result13 = result11[1];
784
- assert.strictEqual(yield result13.isKnown, false);
785
- assert.strictEqual(yield result13.promise(/*withUnknowns*/ true), output_1.unknown);
786
- const output4 = output_1.all({
787
- foo: output_1.unknown,
788
- bar: mockOutput(false, undefined),
789
- baz: output_1.output({ foo: "foo", qux: output_1.unknown }),
790
- });
791
- assert.strictEqual(yield output4.isKnown, false);
792
- const result14 = output4.foo;
793
- assert.strictEqual(yield result14.isKnown, false);
794
- assert.strictEqual(yield result14.promise(/*withUnknowns*/ true), output_1.unknown);
795
- const result15 = output4.bar;
796
- assert.strictEqual(yield result15.isKnown, false);
797
- assert.strictEqual(yield result15.promise(/*withUnknowns*/ true), output_1.unknown);
798
- const result16 = output4.baz;
799
- assert.strictEqual(yield result16.isKnown, false);
800
- const result17 = result16.foo;
801
- assert.strictEqual(yield result17.isKnown, true);
802
- assert.strictEqual(yield result17.promise(/*withUnknowns*/ true), "foo");
803
- const result18 = result16.qux;
804
- assert.strictEqual(yield result18.isKnown, false);
805
- assert.strictEqual(yield result18.promise(/*withUnknowns*/ true), output_1.unknown);
806
- }));
807
- });
808
- });
809
- //# sourceMappingURL=output.spec.js.map