Skip to content
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

(chore) change tests in 27ica/controller to expect specific error #7177

Merged
merged 5 commits into from
Aug 20, 2024

Conversation

bznein
Copy link
Contributor

@bznein bznein commented Aug 15, 2024

Description

closes: #7178


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

suite.Require().Equal(TestVersion, version)
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
suite.Require().ErrorContains(err, tc.expErr.Error())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and all other occurrences using "ErrorContains") is a bit weird but for some reason using ErrorIs fails here :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we have faced this issue other times as well... Something about how the error is wrapped, I think...

@bznein bznein marked this pull request as ready for review August 15, 2024 16:06
@bznein bznein changed the title (chore) changed tests in 27ica/controller to expect specific error (chore) change tests in 27ica/controller to expect specific error Aug 16, 2024
Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @bznein. Thank you so much for taking the initiate to refactor the tests!

suite.Require().Equal(TestVersion, version)
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
suite.Require().ErrorContains(err, tc.expErr.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we have faced this issue other times as well... Something about how the error is wrapped, I think...

@@ -12,33 +12,33 @@ func (suite *KeeperTestSuite) TestQueryInterchainAccount() {
testCases := []struct {
name string
malleate func()
expPass bool
errMsg string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to use expErr here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to. We return errors with status.Errorf which is not the same as wrapping errors. They are not a specific error type

@@ -25,46 +27,46 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount_MsgServer() {

testCases := []struct {
name string
expPass bool
expErr error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: just for consistency with the other tests, we could just switch the order of the last two and have expErr last.

func() {
msg.Ordering = channeltypes.NONE
expectedOrderding = channeltypes.UNORDERED
},
},
{
"invalid connection id",
false,
connectiontypes.ErrConnectionNotFound,
func() {
msg.ConnectionId = "connection-100"
},
},
{
"non-empty owner address is valid",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could also move this test up together with the rest of success cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I actually wanted to do this but also wanted to keep the diff tidy! Now that it has been reviewed I think it makes more sense to move it :)

Copy link

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for cleaning these up

@bznein bznein added this pull request to the merge queue Aug 20, 2024
Merged via the queue into main with commit 1448c59 Aug 20, 2024
69 of 70 checks passed
@bznein bznein deleted the bznein/expectErrors/27ica/controller branch August 20, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use expected errors instead of boolean values for ica controller tests
3 participants