Skip to content

Commit ec5389a

Browse files
authored
Show diffs for all previews (#120)
Currently, a failing preview in a test just shows as something like ``` azure-native:storage:Blob myBlobFile create replacement [diff: ~source] ``` which is not as helpful as it could be diagnose the problem because you don't know _what_ the diff is. We could expose a flag for an optional diff in `optproviderupgrade` but since this is a testing library, I suggest we skip this boilerplate and just turn the diff always on - when would you _not_ want to see the diff on test failure? With this change: ``` +-azure-native:storage:Blob: (replace) [id=/subscriptions/0282681f-7a9e-424b-80b2-96babd57a8a1/resourceGroups/rg1c1afbc6/providers/Microsoft.Storage/storageAccounts/store16dfec76/blobServices/default/containers/assets/blobs/mon-fichier.txt] [urn=urn:pulumi:test::upgrade-storage-blob::azure-native:storage:Blob::myBlobFile] - source: [secret] + source: asset(text:678e7ad) { <contents elided> } ```
1 parent 9fa91f0 commit ec5389a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

previewProviderUpgrade.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/pulumi/providertest/pulumitest/optrun"
1111
"github.com/pulumi/providertest/pulumitest/opttest"
1212
"github.com/pulumi/pulumi/sdk/v3/go/auto"
13+
"github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview"
1314
)
1415

1516
// PreviewProviderUpgrade captures the state of a stack from a baseline provider configuration, then previews the stack
@@ -44,7 +45,7 @@ func PreviewProviderUpgrade(t pulumitest.PT, pulumiTest *pulumitest.PulumiTest,
4445
if options.NewSourcePath != "" {
4546
previewTest.UpdateSource(t, options.NewSourcePath)
4647
}
47-
return previewTest.Preview(t)
48+
return previewTest.Preview(t, optpreview.Diff())
4849
}
4950

5051
func baselineProviderOpt(options optproviderupgrade.PreviewProviderUpgradeOptions, providerName string, baselineVersion string) opttest.Option {

previewProviderUpgrade_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ func TestPreviewUpgradeWithKnownSourceEdit(t *testing.T) {
4343
optproviderupgrade.NewSourcePath(filepath.Join("pulumitest", "testdata", "yaml_program_updated")),
4444
)
4545

46-
assert.Contains(t, previewResult.StdOut, "random:index:RandomPassword password create")
46+
assert.Contains(t, previewResult.StdOut, "random:index/randomPassword:RandomPassword::password")
47+
assert.Contains(t, previewResult.StdOut, "+ 1 to create\n")
4748
}
4849

4950
func TestPreviewWithInvokeReplayed(t *testing.T) {

0 commit comments

Comments
 (0)