Skip to content

Commit b88c0b2

Browse files
authored
Add l1-config-types-optional conformance test (#23108)
## Summary Adds an `l1-config-types-optional` conformance test for the `optional` type constructor in PCL added in #22547. The test exercises `list(optional(string))` with a default value containing `null` entries and verifies that each language SDK can use the resulting list at runtime. - Passes for PCL, NodeJS (TSC, TSNode, Bun), and Python (Default, TOML, Classes). - Added to Go's `expectedFailures` because the Go SDK codegen emits a call to `cfg.GetObject` with the wrong signature for complex config types — the same pre-existing problem already tracked by `l1-config-types-object`. ## Test plan - [x] `./scripts/run-conformance.sh l1-config-types-optional` passes locally for PCL, NodeJS, and Python - [x] Go test is correctly skipped via `expectedFailures` - [x] `TestTestNames` / `TestL1NoProviders` pass
1 parent 4b708ec commit b88c0b2

37 files changed

Lines changed: 289 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changes:
2+
- type: feat
3+
scope: pkg/testing
4+
description: Add `l1-config-types-optional` conformance test for PCL's `optional` type constructor
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2026, Pulumi Corporation.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package tests
16+
17+
import (
18+
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
19+
"github.com/stretchr/testify/assert"
20+
)
21+
22+
func init() {
23+
LanguageTests["l1-config-types-optional"] = LanguageTest{
24+
Runs: []TestRun{
25+
{
26+
Assert: func(l *L, res AssertArgs) {
27+
RequireStackResource(l, res.Err, res.Changes)
28+
stack := RequireSingleResource(l, res.Snap.Resources, "pulumi:pulumi:Stack")
29+
30+
assert.Equal(l, resource.PropertyMap{
31+
"namesLength": resource.NewProperty(3.0),
32+
}, stack.Outputs)
33+
},
34+
},
35+
},
36+
}
37+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
config "names" "list(optional(string))" {
2+
default = [null, "hello", null]
3+
}
4+
5+
output "namesLength" {
6+
value = length(names)
7+
}

‎sdk/go/pulumi-language-go/language_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func runTestingHost(t *testing.T) (string, testingrpc.LanguageTestClient) {
100100
// Add test names here that are expected to fail and the reason why they are failing
101101
var expectedFailures = map[string]string{
102102
"l1-config-types-object": "fails to compile",
103+
"l1-config-types-optional": "fails to compile: cfg.GetObject signature mismatch (same as l1-config-types-object)", //nolint:lll
103104
"l1-builtin-try": "pulumi#18506 Support try in Go program generation",
104105
"l1-builtin-can": "pulumi#18570 Support can in Go program generation",
105106
"l1-builtin-list": "list(string) config decoded as string; element/split emit TODO stubs",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/bin/
2+
/node_modules/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: l1-config-types-optional
2+
runtime: bun
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as pulumi from "@pulumi/pulumi";
2+
3+
const config = new pulumi.Config();
4+
const names = config.getObject<Array<string>>("names") || [
5+
null,
6+
"hello",
7+
null,
8+
];
9+
export const namesLength = names.length;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "l1-config-types-optional",
3+
"main": "index.ts",
4+
"type": "module",
5+
"devDependencies": {
6+
"@types/bun": "latest"
7+
},
8+
"peerDependencies": {
9+
"typescript": "^5"
10+
},
11+
"dependencies": {
12+
"@pulumi/pulumi": "ROOT/artifacts/pulumi-pulumi-CORE.VERSION.tgz"
13+
}
14+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
// Environment setup & latest features
4+
"lib": ["ESNext"],
5+
"target": "ESNext",
6+
"module": "Preserve",
7+
"moduleDetection": "force",
8+
"jsx": "react-jsx",
9+
"allowJs": true,
10+
// Bundler mode
11+
"moduleResolution": "bundler",
12+
"allowImportingTsExtensions": true,
13+
"verbatimModuleSyntax": true,
14+
"noEmit": true,
15+
// Best practices
16+
"strict": true,
17+
"skipLibCheck": true,
18+
"noFallthroughCasesInSwitch": true,
19+
"noUncheckedIndexedAccess": true,
20+
"noImplicitOverride": true,
21+
// Some stricter flags (disabled by default)
22+
"noUnusedLocals": false,
23+
"noUnusedParameters": false,
24+
"noPropertyAccessFromIndexSignature": false
25+
},
26+
"files": [
27+
"index.ts",
28+
]
29+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/bin/
2+
/node_modules/

0 commit comments

Comments
 (0)