diff --git a/tests/sdk/java/preview_test.go b/tests/sdk/java/preview_test.go new file mode 100644 index 0000000000..f850b00c22 --- /dev/null +++ b/tests/sdk/java/preview_test.go @@ -0,0 +1,23 @@ +package test + +import ( + "testing" + + "github.com/pulumi/providertest/pulumitest" + "github.com/pulumi/providertest/pulumitest/opttest" +) + +// TestPreviewReplacements ensures that replacements for immutable fields are correctly previewed. +func TestPreviewReplacements(t *testing.T) { + test := pulumitest.NewPulumiTest(t, "testdata/preview-replacements", opttest.SkipInstall()) + t.Logf("into %s", test.Source()) + t.Cleanup(func() { + test.Destroy() + }) + test.Preview() + test.Up() + + // Preview should not fail when there is a replacement due to immutable fields. + test.UpdateSource("testdata/preview-replacements", "step2") + test.Preview() +} diff --git a/tests/sdk/java/testdata/preview-replacements/Pulumi.yaml b/tests/sdk/java/testdata/preview-replacements/Pulumi.yaml new file mode 100644 index 0000000000..c6a6569804 --- /dev/null +++ b/tests/sdk/java/testdata/preview-replacements/Pulumi.yaml @@ -0,0 +1,32 @@ +name: job-unreachable +runtime: yaml +resources: + provider: + type: pulumi:providers:kubernetes + ns: + type: kubernetes:core/v1:Namespace + options: + provider: ${provider} + job: + type: kubernetes:batch/v1:Job + properties: + metadata: + name: test-job-previews + namespace: ${ns.metadata.name} + annotations: + pulumi.com/skipAwait: "true" + spec: + template: + metadata: + name: test-job-unreachable + spec: + containers: + - name: test-job-unreachable-container + image: busybox + command: + - sh + - -c + - exit 0 + restartPolicy: Never + options: + provider: ${provider} diff --git a/tests/sdk/java/testdata/preview-replacements/step2/Pulumi.yaml b/tests/sdk/java/testdata/preview-replacements/step2/Pulumi.yaml new file mode 100644 index 0000000000..84675fd46a --- /dev/null +++ b/tests/sdk/java/testdata/preview-replacements/step2/Pulumi.yaml @@ -0,0 +1,32 @@ +name: job-unreachable +runtime: yaml +resources: + provider: + type: pulumi:providers:kubernetes + ns: + type: kubernetes:core/v1:Namespace + options: + provider: ${provider} + job: + type: kubernetes:batch/v1:Job + properties: + metadata: + name: test-job-previews + namespace: ${ns.metadata.name} + annotations: + pulumi.com/skipAwait: "true" + spec: + template: + metadata: + name: test-job-unreachable + spec: + containers: + - name: test-job-unreachable-container-step2 + image: busybox + command: + - sh + - -c + - exit 0 + restartPolicy: Never + options: + provider: ${provider}