-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: support in-place migration ordering (#10614) ## Description Closes: #10604 --- ### 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 - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/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 - [ ] 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](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) (cherry picked from commit da92921) # Conflicts: # CHANGELOG.md # docs/core/upgrade.md # types/errors/errors.go # types/module/module.go * conflict fix * Add Features section * fix conflicts Co-authored-by: Robert Zaremba <robert@zaremba.ch>
- Loading branch information
1 parent
6d44d71
commit 8932338
Showing
6 changed files
with
140 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package module | ||
|
||
import ( | ||
"sort" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
func TestModuleIntSuite(t *testing.T) { | ||
suite.Run(t, new(TestSuite)) | ||
} | ||
|
||
type TestSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func (s TestSuite) TestAssertNoForgottenModules() { | ||
m := Manager{ | ||
Modules: map[string]AppModule{"a": nil, "b": nil}, | ||
} | ||
tcs := []struct { | ||
name string | ||
positive bool | ||
modules []string | ||
}{ | ||
{"same modules", true, []string{"a", "b"}}, | ||
{"more modules", true, []string{"a", "b", "c"}}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
if tc.positive { | ||
m.assertNoForgottenModules("x", tc.modules) | ||
} else { | ||
s.Panics(func() { m.assertNoForgottenModules("x", tc.modules) }) | ||
} | ||
} | ||
} | ||
|
||
func (s TestSuite) TestModuleNames() { | ||
m := Manager{ | ||
Modules: map[string]AppModule{"a": nil, "b": nil}, | ||
} | ||
ms := m.ModuleNames() | ||
sort.Strings(ms) | ||
s.Require().Equal([]string{"a", "b"}, ms) | ||
} | ||
|
||
func (s TestSuite) TestDefaultMigrationsOrder() { | ||
require := s.Require() | ||
require.Equal( | ||
[]string{"auth2", "d", "z", "auth"}, | ||
DefaultMigrationsOrder([]string{"d", "auth", "auth2", "z"}), "alphabetical, but auth should be last") | ||
require.Equal( | ||
[]string{"auth2", "d", "z"}, | ||
DefaultMigrationsOrder([]string{"d", "auth2", "z"}), "alphabetical") | ||
} |