Skip to content

Commit

Permalink
Upgrade to the latest PulumiTest version
Browse files Browse the repository at this point in the history
  • Loading branch information
t0yv0 committed Dec 23, 2024
1 parent 57e4dde commit e1e6ee6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions tests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func TestIgnoringScalingChanges(t *testing.T) {
}

pt := pulumitest.NewPulumiTest(t, dir, options...)
pt.SetConfig("aws:region", getEnvRegion(t))
pt.SetConfig("desiredSize", "1")
pt.SetConfig(t, "aws:region", getEnvRegion(t))
pt.SetConfig(t, "desiredSize", "1")

cacheDir := filepath.Join("testdata", "recorded", t.Name())
err = os.MkdirAll(cacheDir, 0o755)
Expand All @@ -129,25 +129,25 @@ func TestIgnoringScalingChanges(t *testing.T) {
var export *apitype.UntypedDeployment
export, err = tryReadStackExport(stackExportFile)
if err != nil {
pt.Up()
grpcLog := pt.GrpcLog()
pt.Up(t)
grpcLog := pt.GrpcLog(t)
grpcLogPath := filepath.Join(cacheDir, "grpc.json")
t.Logf("writing grpc log to %s", grpcLogPath)
err = grpcLog.WriteTo(grpcLogPath)
require.NoError(t, err)

e := pt.ExportStack()
e := pt.ExportStack(t)
export = &e
err = writeStackExport(stackExportFile, export, true)
require.NoError(t, err)
} else {
pt.ImportStack(*export)
pt.ImportStack(t, *export)
}

// Change the desiredSize, but expect no changes because it should be ignored
pt.SetConfig("desiredSize", "2")
pt.SetConfig(t, "desiredSize", "2")
// TODO: uncomment after v3
pt.Preview( /*optpreview.ExpectNoChanges(),*/ optpreview.Diff())
pt.Preview(t /*optpreview.ExpectNoChanges(),*/, optpreview.Diff())
}

func TestEksAuthModeUpgrade(t *testing.T) {
Expand Down Expand Up @@ -212,7 +212,7 @@ resources:
},
})

res := pulumiTest.Preview()
res := pulumiTest.Preview(t)
fmt.Printf("stdout: %s \n", res.StdOut)
fmt.Printf("stderr: %s \n", res.StdErr)
assertpreview.HasNoReplacements(t, res)
Expand Down Expand Up @@ -283,19 +283,19 @@ func testProviderCodeChanges(t *testing.T, opts *testProviderCodeChangesOptions)
if opts != nil && opts.region != "" {
region = opts.region
}
pt.SetConfig("aws:region", region)
pt.SetConfig(t, "aws:region", region)

var export *apitype.UntypedDeployment
export, err = tryReadStackExport(stackExportFile)
if err != nil {
pt.Up()
grpcLog := pt.GrpcLog()
pt.Up(t)
grpcLog := pt.GrpcLog(t)
grpcLogPath := filepath.Join(cacheDir, "grpc.json")
t.Logf("writing grpc log to %s", grpcLogPath)
err = grpcLog.WriteTo(grpcLogPath)
require.NoError(t, err)

e := pt.ExportStack()
e := pt.ExportStack(t)
export = &e
err = writeStackExport(stackExportFile, export, true)
require.NoError(t, err)
Expand All @@ -312,8 +312,8 @@ func testProviderCodeChanges(t *testing.T, opts *testProviderCodeChangesOptions)
err = os.WriteFile(filepath.Join(workdir, "Pulumi.yaml"), opts.secondProgram, 0o600)
require.NoError(t, err)
secondTest := pulumitest.NewPulumiTest(t, workdir, secondOptions...)
secondTest.SetConfig("aws:region", region)
secondTest.ImportStack(*export)
secondTest.SetConfig(t, "aws:region", region)
secondTest.ImportStack(t, *export)

return secondTest
}
Expand Down
6 changes: 3 additions & 3 deletions tests/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func checkEksClusterInputValidations(t *testing.T, property string, n int, expec
}
tw := &testWrapper{PT: t, expectFailure: expectFailure}
test := pulumitest.NewPulumiTest(tw, dir, options...)
test.SetConfig("property", property)
test.SetConfig("n", fmt.Sprintf("%d", n))
test.Preview()
test.SetConfig(t, "property", property)
test.SetConfig(t, "n", fmt.Sprintf("%d", n))
test.Preview(t)
if expectFailure {
require.Truef(t, tw.failed, "Expected preview to fail due to invalid inputs but it succeeded")
}
Expand Down

0 comments on commit e1e6ee6

Please sign in to comment.