-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
test(cosmovisor): improve TestParseUpgradeInfoFile with substring assertions #18262
Conversation
WalkthroughThe changes enhance error reporting in the Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 894bebc and 6389f6d484aecbdf413adf4c337ee478f57e0331.Files ignored due to filter (1)
- tools/cosmovisor/testdata/upgrade-files/f3-empty.json
Files selected for processing (2)
- tools/cosmovisor/scanner.go (1 hunks)
- tools/cosmovisor/scanner_test.go (2 hunks)
Files skipped from review due to trivial changes (1)
- tools/cosmovisor/scanner_test.go
Additional comments: 1
tools/cosmovisor/scanner.go (1)
- 192-192: The error message has been improved to include the filename, which will provide more context when debugging. This is a good practice as it helps to quickly identify the source of the problem.
6389f6d
to
b2a4a57
Compare
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 894bebc and b2a4a574a511c19900e956e083c86b525e8467d7.Files ignored due to filter (1)
- tools/cosmovisor/testdata/upgrade-files/f3-empty.json
Files selected for processing (2)
- tools/cosmovisor/scanner.go (1 hunks)
- tools/cosmovisor/scanner_test.go (2 hunks)
Files skipped from review due to trivial changes (1)
- tools/cosmovisor/scanner_test.go
Additional comments: 1
tools/cosmovisor/scanner.go (1)
- 192-192: The error message has been improved to include the filename when the upgrade-info.json file is empty. This change provides more context and makes it easier to identify the source of the error.
- return upgradetypes.Plan{}, errors.New("empty upgrade-info.json") + return upgradetypes.Plan{}, fmt.Errorf("empty upgrade-info.json in %q", filename)Committable suggestion (Beta)
if len(f) == 0 { return upgradetypes.Plan{}, fmt.Errorf("empty upgrade-info.json in %q", filename) }
b2a4a57
to
eb06fed
Compare
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 331e106 and 4358c2a0cdfb4960082578fdc1082237aaab5b49.Files ignored due to filter (1)
- tools/cosmovisor/testdata/upgrade-files/f3-empty.json
Files selected for processing (2)
- tools/cosmovisor/scanner.go (2} hunks)
- tools/cosmovisor/scanner_test.go (2} hunks)
Files skipped from review due to trivial changes (1)
- tools/cosmovisor/scanner_test.go
Additional comments: 2
tools/cosmovisor/scanner.go (2)
192-192: The error message for an empty upgrade-info.json file now includes the filename, providing more specific context about the error source. This is a good practice as it helps in debugging by providing more detailed error messages.
210-210: The function now returns
nil
instead oferr
as the error. This change is correct if we assume that any error would have been returned earlier in the function. However, it's important to ensure that all error cases are indeed handled before this point in the function.- return upgradePlan, err + return upgradePlan, nilCommittable suggestion (Beta)
upgradePlan.Name = strings.ToLower(upgradePlan.Name) } return upgradePlan, nil }
4358c2a
to
940b38d
Compare
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between e0d84b7 and 940b38d83e6e085b8ffdcd96cc86a075d5510252.Files ignored due to filter (1)
- tools/cosmovisor/testdata/upgrade-files/f3-empty.json
Files selected for processing (2)
- tools/cosmovisor/scanner.go (2} hunks)
- tools/cosmovisor/scanner_test.go (2} hunks)
Files skipped from review due to trivial changes (1)
- tools/cosmovisor/scanner_test.go
Additional comments: 2
tools/cosmovisor/scanner.go (2)
192-192: The error message for an empty upgrade-info.json file now includes the filename, providing more context about the error source. This is a good practice as it helps in debugging by providing more specific information about the error.
210-210: The function now returns
nil
instead oferr
in the case where there is no error. This is a good practice as it makes the function's behavior more predictable and consistent. It's important to always returnnil
when there's no error, rather than a potentially uninitialized error variable.
940b38d
to
8537b5a
Compare
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- tools/cosmovisor/testdata/upgrade-files/f3-empty.json
Files selected for processing (2)
- tools/cosmovisor/scanner.go (2} hunks)
- tools/cosmovisor/scanner_test.go (2} hunks)
Files skipped from review due to trivial changes (1)
- tools/cosmovisor/scanner_test.go
Additional comments: 2
tools/cosmovisor/scanner.go (2)
192-192: The error message for an empty upgrade-info.json file now includes the filename, providing more context about the error source. This is a good practice as it helps in debugging by providing more specific information about the error.
210-210: The function now returns
nil
instead oferr
in the case where there is no error. This is a good practice as it makes the code more readable and understandable. It's clear that if the function reaches this point, no error has occurred.
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.
👍
Looks like we've got 2 odd test failures. Am gonna whip out my laptop and examine them. |
…ertions In trying to investigate the flake reported in #18073, this change adds the context of the failing test's filepath. This change allows us to tighten the tests by using assertions on the error instead of just checking that it is non-nil. Also one of the tests that claimed it was empty actually had a space/newline which meant that it wasn't testing the right expectations. Updates #18073
3b69405
to
42c90bf
Compare
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- tools/cosmovisor/testdata/upgrade-files/f3-empty.json
Files selected for processing (2)
- tools/cosmovisor/scanner.go (2} hunks)
- tools/cosmovisor/scanner_test.go (2} hunks)
Files skipped from review due to trivial changes (1)
- tools/cosmovisor/scanner_test.go
Additional comments: 2
tools/cosmovisor/scanner.go (2)
192-192: The error message has been improved to include the filename of the problematic file. This is a good change as it provides more context to the error and can help in debugging.
210-210: The function now returns
nil
instead oferr
in the case of no errors. This is a good change as it makes the error handling more explicit and clear.
…ertions (#18262) Co-authored-by: Marko <[email protected]>
In trying to investigate the flake reported in #18073, this change adds the context of the failing test's filepath. This change allows us to tighten the tests by using assertions on the error instead of just checking that it is non-nil.
Also one of the tests that claimed it was empty actually had a space/newline which meant that it wasn't testing the right expectations.
Updates #18073
Summary by CodeRabbit
parseUpgradeInfoFile
function. Now, if theupgrade-info.json
file is empty, the error message will include the filename, making it easier to identify the source of the issue.TestParseUpgradeInfoFile
function. The test cases now expect specific error messages, providing more precise error reporting during testing.