-
Notifications
You must be signed in to change notification settings - Fork 178
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
fix: Fixes migration tests for backup_online_archive #1724
Conversation
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.
Like this approach 💯 , will definitely help for defining migrations tests for new attributes or breaking changes.
internal/testutil/mig/provider.go
Outdated
} | ||
} | ||
|
||
func ValueIfVersionAtLeast[T any](tb testing.TB, val T, minVersion string) T { |
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.
func ValueIfVersionAtLeast[T any](tb testing.TB, val T, minVersion string) T { | |
func ConfiguredProviderVersionAtLeast(tb testing.TB, minVersion string) bool |
nit: might find it easier to follow if this function returns a boolean, and then each function that generates a configuration uses that boolean to their preference (passing default value, or using the boolean itself to define a set of attributes in the config).
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.
makes sense, changed
internal/testutil/mig/pre_check.go
Outdated
func PreCheckBasic(tb testing.TB) { | ||
checkLastVersion(tb) | ||
acc.PreCheckBasic(tb) | ||
} |
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.
you should consider enabling thelper
in the linter, this and all test helpers should be
func PreCheckBasic(tb testing.TB) { | |
checkLastVersion(tb) | |
acc.PreCheckBasic(tb) | |
} | |
func PreCheckBasic(tb testing.TB) { | |
tb.Helper() | |
checkLastVersion(tb) | |
acc.PreCheckBasic(tb) | |
} |
It will report the failing test correctly instead of flagging this function
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.
ohhh. right, thanks!
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.
@gssbzn is there a problem if tb.Helper is called multiple times? e.g. one helper method calls another, but both can be called from tests.
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.
b.Helper is called multiple times?
No internally it flags to not consider the line but the caller the failure which will bubble up if a helper calls a helper
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.
thx, changed
@@ -98,6 +98,13 @@ linters: | |||
- unconvert | |||
- unused | |||
- whitespace | |||
- thelper |
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.
add some linters as in CLI
|
Description
Fixes migration tests for backup_online_archive.
data_expiration_rule
was introduced in 1.12.2 so it can't be used before.It also refactors mig (migration) helper methods.
Link to any related issue(s):
Type of change:
Required Checklist:
Further comments