Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade tests with known source edits #95

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions optproviderupgrade/optproviderupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ func CacheDir(elem ...string) PreviewProviderUpgradeOpt {
})
}

func NewSourcePath(path string) PreviewProviderUpgradeOpt {
return optionFunc(func(o *PreviewProviderUpgradeOptions) {
o.NewSourcePath = path
})
}

type PreviewProviderUpgradeOptions struct {
CacheDirTemplate []string
DisableAttach bool
BaselineOpts []opttest.Option
NewSourcePath string
}

type PreviewProviderUpgradeOpt interface {
Expand Down
4 changes: 4 additions & 0 deletions previewProviderUpgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func PreviewProviderUpgrade(t pulumitest.PT, pulumiTest *pulumitest.PulumiTest,
baselineProviderOpt(options, providerName, baselineVersion)),
optrun.WithOpts(options.BaselineOpts...),
)

if options.NewSourcePath != "" {
previewTest.UpdateSource(options.NewSourcePath)
}
return previewTest.Preview()
}

Expand Down
15 changes: 15 additions & 0 deletions previewProviderUpgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,18 @@ func TestPreviewUpgradeCached(t *testing.T) {
optproviderupgrade.DisableAttach())
assert.Equal(t, uncachedPreviewResult, cachedPreviewResult, "expected uncached and cached preview to be the same")
}

func TestPreviewUpgradeWithKnownSourceEdit(t *testing.T) {
t.Parallel()
cacheDir := t.TempDir()
test := pulumitest.NewPulumiTest(t, filepath.Join("pulumitest", "testdata", "yaml_program"),
opttest.DownloadProviderVersion("random", "4.15.0"))

previewResult := providertest.PreviewProviderUpgrade(t, test, "random", "4.5.0",
optproviderupgrade.CacheDir(cacheDir, "{programName}", "{baselineVersion}"),
optproviderupgrade.DisableAttach(),
optproviderupgrade.NewSourcePath(filepath.Join("pulumitest", "testdata", "yaml_program_updated")),
)

assert.Contains(t, previewResult.StdOut, "random:index:RandomPassword password create")
}
Loading