diff --git a/tests/sdk/java/autonaming_test.go b/tests/sdk/java/autonaming_test.go new file mode 100644 index 0000000000..64d17e4b54 --- /dev/null +++ b/tests/sdk/java/autonaming_test.go @@ -0,0 +1,23 @@ +package test + +import ( + "testing" + + "github.com/pulumi/providertest/pulumitest" + "github.com/pulumi/providertest/pulumitest/opttest" + "github.com/stretchr/testify/assert" +) + +// TestAutonaming ensures that custom resource autonaming configuration works as expected. +func TestAutonaming(t *testing.T) { + test := pulumitest.NewPulumiTest(t, "testdata/autonaming", opttest.SkipInstall(), opttest.Env("PULUMI_EXPERIMENTAL", "1")) + t.Logf("into %s", test.Source()) + t.Cleanup(func() { + test.Destroy(t) + }) + test.Preview(t) + up := test.Up(t) + nsname, ok := up.Outputs["nsname"].Value.(string) + assert.True(t, ok) + assert.Contains(t, nsname, "autonaming-ns-") // project + name + random suffix +} diff --git a/tests/sdk/java/testdata/autonaming/Pulumi.yaml b/tests/sdk/java/testdata/autonaming/Pulumi.yaml new file mode 100644 index 0000000000..8db724563c --- /dev/null +++ b/tests/sdk/java/testdata/autonaming/Pulumi.yaml @@ -0,0 +1,11 @@ +name: autonaming +runtime: yaml +config: + pulumi:autonaming: + value: + pattern: ${project}-${name}-${alphanum(6)} +outputs: + nsname: ${ns.metadata.name} +resources: + ns: + type: kubernetes:core/v1:Namespace