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

test: fix gomock controller finish #1231

Merged
merged 7 commits into from
Sep 5, 2023
Merged

Conversation

dadamu
Copy link
Contributor

@dadamu dadamu commented Sep 5, 2023

Description

This PR fixes the gomock controller finish by moving it to the TearDownTest phase, or it cannot find the missing calls of the function we setup on expected keepers.

It also fixes the tests having wrong setting on the expected keepers.


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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@dadamu dadamu requested a review from a team as a code owner September 5, 2023 08:20
@github-actions github-actions bot added x/profiles Module that allows to create and manage decentralized social profiles x/subspaces Issue on the x/subspaces module x/relationships labels Sep 5, 2023
@@ -291,34 +291,12 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() {
func (suite *KeeperTestSuite) TestKeeper_ImportGenesis() {
testCases := []struct {
name string
setup func()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ImportGenesis does not require any expected keepers setting.

Comment on lines -104 to -111
suite.sk.EXPECT().
GetSubspace(gomock.Any(), uint64(1)).
Return(
types.Subspace{
AdditionalFeeTokens: sdk.NewCoins(sdk.NewCoin("minttoken", sdk.NewInt(1))),
},
true,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

manage subspace transaction does not check the subspaces additional fee tokens.

@@ -1491,14 +1491,6 @@ func (suite *KeeperTestSuite) TestMsgServer_RemovePostAttachment() {
"cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd",
subspacestypes.NewPermission(types.PermissionModerateContent),
).Return(false)

suite.sk.EXPECT().HasPermission(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not check the EditOwnContent permission when post owner does not match the message sender.

@@ -669,7 +669,7 @@ func (suite *KeeperTestSuite) TestMsgServer_EditPost() {
types.REPLY_SETTING_EVERYONE,
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
"cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4",
"cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd",
Copy link
Contributor Author

@dadamu dadamu Sep 5, 2023

Choose a reason for hiding this comment

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

We should ensure the the owner of post stored is the same as the sender without EditOwnContent permission in this test

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Patch has no changes to coverable lines.

📢 Thoughts on this report? Let us know!.

@@ -1170,7 +1170,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddPostAttachment() {
gomock.Any(),
uint64(1),
uint32(0),
"cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4",
"cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should ensure the the owner of post stored is the same as the sender without EditOwnContent permission in this test.

@@ -1189,7 +1189,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddPostAttachment() {
types.REPLY_SETTING_EVERYONE,
time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC),
nil,
"cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4",
"cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

@@ -1845,6 +1837,24 @@ func (suite *KeeperTestSuite) TestMsgServer_AnswerPoll() {
subspacestypes.NewPermission(types.PermissionInteractWithContent),
).Return(false)
},
store: func(ctx sdk.Context) {
suite.k.SavePost(ctx, types.NewPost(
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 is missing post should be stored before the test.

@@ -3282,7 +3292,6 @@ func (suite *KeeperTestSuite) TestMsgServer_RequestPostOwnerTransfer() {
func (suite *KeeperTestSuite) TestMsgServer_CancelPostOwnerTransfer() {
testCases := []struct {
name string
setup func()
Copy link
Contributor Author

@dadamu dadamu Sep 5, 2023

Choose a reason for hiding this comment

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

CancelPostOwnerTransfer does not require expected keepers setting

@@ -3649,7 +3639,6 @@ func (suite *KeeperTestSuite) TestMsgServer_AcceptPostOwnerTransfer() {
func (suite *KeeperTestSuite) TestMsgServer_RefusePostOwnerTransfer() {
testCases := []struct {
name string
setup func()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above, RefusePostOwnerTransfer does not require expected keepers setting

Copy link
Contributor

@RiccardoM RiccardoM left a comment

Choose a reason for hiding this comment

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

Great job! 💯

@RiccardoM RiccardoM merged commit da5f561 into master Sep 5, 2023
33 checks passed
@RiccardoM RiccardoM deleted the paul/fix-gomock-finish branch September 5, 2023 16:47
RiccardoM added a commit that referenced this pull request Oct 10, 2023
## Description

~~Deps: #1231~~
This PR improves `x/profiles` by mutation tests to increase mutation
score of `x/profiles` to 0.887324.


```
################################################################################
### WARNING! This test will take hours to complete!
################################################################################
running mutation tests for the following module(s): profiles
writing mutation test result to mutation_test_result.txt
The mutation score is 0.887324 (252 passed, 2 failed, 0 duplicated, 30 skipped, total is 284)
```

<!-- Add a description of the changes that this PR introduces and the
files that
are the most critical to review. -->

---

### 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...

- [x] included the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR
Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building
modules](https://docs.cosmos.network/v0.44/building-modules/intro.html)
- [ ] included the necessary unit and integration
[tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go
code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### 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...

- [ ] confirmed the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

---------

Co-authored-by: Riccardo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x/profiles Module that allows to create and manage decentralized social profiles x/relationships x/subspaces Issue on the x/subspaces module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants