-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(types/coin): add unit tests for the coins #20253
test(types/coin): add unit tests for the coins #20253
Conversation
WalkthroughThe recent changes focus on enriching the unit testing suite in Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
if !tc.valid { | ||
s.Require().Error(err, "%s: %#v. tc #%d", tc.input, res, tcIndex) | ||
} else if s.Assert().Nil(err, "%s: %+v", tc.input, err) { | ||
s.Require().Equal(tc.expected, res, "coin parsing was incorrect, tc #%d", tcIndex) |
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.
s.Require().Equal(tc.expected, res, "coin parsing was incorrect, tc #%d", tcIndex) | |
s.Require().Equal(tc.expected, res, "coin parsing was correct, tc #%d", tcIndex) |
Correct me if im wrong, we in scope err = nil right?
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.
The message coin parsing was incorrect, tc <index>
will be printed only when expected
and res
are not equal
types/coin_test.go
Outdated
res, err := sdk.ParseCoinNormalized(tc.input) | ||
if !tc.valid { | ||
s.Require().Error(err, "%s: %#v. tc #%d", tc.input, res, tcIndex) | ||
} else if s.Assert().Nil(err, "%s: %+v", tc.input, err) { |
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.
How about checking condition tc.valid then make sure err is nil & res equal to expected in scope.
} else if s.Assert().Nil(err, "%s: %+v", tc.input, err) { | |
} else { | |
s.Assert().Nil(err) | |
... | |
} |
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.
done
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.
Actionable comments posted: 0
Review Details
Configuration used: .coderabbit.yml
Review profile: CHILL
Commits
Files that changed from the base of the PR and between 5637794 and faad9fb6ec4443df59085df87c8dec34637d4bd6.Files selected for processing (1)
- types/coin_test.go (3 hunks)
Additional Context Used
Path-based Instructions (1)
types/coin_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Additional comments not posted (4)
types/coin_test.go (4)
644-657
: The test functionTestCoinsAddUnorderedDenominations
correctly checks for panics when adding unordered denominations, which aligns with expected behavior.
1411-1421
: The test functionTestGetDenomByIndex
correctly retrieves denominations by index and validates them, which is crucial for ensuring the integrity of coin handling.
1423-1453
: The test functionTestIsAllPositive
effectively checks for positive coin values across different scenarios, ensuring robustness in coin value validation.
1455-1490
: The test functionTestParseCoin
provides comprehensive test coverage for parsing coin strings, ensuring that the parsing logic handles a variety of scenarios correctly.
faad9fb
to
53dff38
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.
LGTM thank you!
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit