-
Notifications
You must be signed in to change notification settings - Fork 0
Pass T explicitly to all methods
#102
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
Conversation
- Remove `t` from the PulumiTest struct. - Fix calls between methods.
Run the following migration: ``` gofmt -r 'a.Convert(b) -> a.Convert(t, b)' -w ./**/*.go gofmt -r 'a.a.CopyTo(b) -> a.a.CopyTo(t, b)' -w ./**/*.go gofmt -r 'a.CopyToTempDir() -> a.CopyToTempDir(t)' -w ./**/*.go gofmt -r 'a.Destroy() -> a.Destroy(t)' -w ./**/*.go gofmt -r 'a.ExportStack() -> a.ExportStack(t)' -w ./**/*.go gofmt -r 'a.GrpcLog() -> a.GrpcLog(t)' -w ./**/*.go gofmt -r 'a.ClearGrpcLog() -> a.ClearGrpcLog(t)' -w ./**/*.go gofmt -r 'a.Import(b, c, d, e, f, g) -> a.Import(t, b, c, d, e, f, g)' -w ./**/*.go gofmt -r 'a.Import(b, c, d, e, f) -> a.Import(t, b, c, d, e, f)' -w ./**/*.go gofmt -r 'a.Import(b, c, d, e) -> a.Import(t, b, c, d, e)' -w ./**/*.go gofmt -r 'a.Import(b, c, d) -> a.Import(t, b, c, d)' -w ./**/*.go gofmt -r 'a.Import(b, c) -> a.Import(t, b, c)' -w ./**/*.go gofmt -r 'a.Import(b) -> a.Import(t, b)' -w ./**/*.go gofmt -r 'a.ImportStack(b) -> a.ImportStack(t, b)' -w ./**/*.go gofmt -r 'a.Install() -> a.Install(t)' -w ./**/*.go gofmt -r 'a.InstallStack(b) -> a.InstallStack(t, b)' -w ./**/*.go gofmt -r 'a.Preview() -> a.Preview(t)' -w ./**/*.go gofmt -r 'a.Refresh() -> a.Refresh(t)' -w ./**/*.go gofmt -r 'a.SetConfig(b, c) -> a.SetConfig(t, b, c)' -w ./**/*.go gofmt -r 'a.Up() -> a.Up(t)' -w ./**/*.go gofmt -r 'a.UpdateSource(b) -> a.UpdateSource(t, b)' -w ./**/*.go gofmt -r 'a.NewStack(b) -> a.NewStack(t, b)' -w ./**/*.go gofmt -r 'a.Run(b) -> a.Run(t, b)' -w ./**/*.go ``` The only manual tweak needed is for pt.Run where 1 additional option is passed. We can't have a rule for 'a.Run(b, c) -> a.Run(t, b, c)' because it would also affect all uses of sub-tests. The pt.Run function is not widely used directly as it's a helper designed for upgrade testing.
iwahbe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unfortunate change, but I think a positive one. LGTM
flostadler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely a useful change! LGTM
I love that you created a migration script!
|
This PR has been shipped in release v0.1.0. |
Don't capture T within the PulumiTest structure as this breaks various aspects of how Go's testing is designed:
Tinstance so if we create a copy of apulumitestinstance for a sub-test, we don't want logs reported to the parent.pulumitestrather than the line of the operation that failed.Fixes #104
Why pass in
T?Solution
Migration Script
We can fix pretty much all usages using
gofmt.. Re-testing shows this works.gofmtseems unable to migrate thept.Run()because it can't match inline functionsImportmigration isn't idempotent due to the variable number of arguments so should be run once manually when upgrading to the new version and the changes committed.