-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add test suite for the cli tests (#3715)
* add suite extension for the cli tests * fix test lock for network * fix missing vars in template * add a flag to check if the network mutex is locked * reset the config for each test in the cli pkg * fix test suite parameter for CLI test * wait for the next block to execute the tests * update changelog --------- Co-authored-by: Pantani <Pantani> Co-authored-by: Jerónimo Albi <[email protected]>
- Loading branch information
1 parent
897b1cc
commit 4a94461
Showing
9 changed files
with
251 additions
and
205 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
54 changes: 54 additions & 0 deletions
54
ignite/templates/module/create/files/base/x/{{moduleName}}/client/cli/suite_test.go.plush
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,54 @@ | ||
package cli_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"<%= modulePath %>/testutil/network" | ||
) | ||
|
||
type IntegrationTestSuite struct { | ||
suite.Suite | ||
|
||
locked bool | ||
net *network.Network | ||
cfg network.Config | ||
} | ||
|
||
func (s *IntegrationTestSuite) network() *network.Network { | ||
s.net = network.New(s.T(), s.cfg) | ||
s.locked = true | ||
return s.net | ||
} | ||
|
||
func (s *IntegrationTestSuite) waitForNextBlock() { | ||
s.T().Log("wait for next block") | ||
s.Require().NoError(s.net.WaitForNextBlock()) | ||
} | ||
|
||
func (s *IntegrationTestSuite) SetupTest() { | ||
s.T().Log("setting up test") | ||
s.cfg = network.DefaultConfig() | ||
} | ||
|
||
func (s *IntegrationTestSuite) SetupSuite() { | ||
s.T().Log("setting up integration test suite") | ||
s.cfg = network.DefaultConfig() | ||
} | ||
|
||
func (s *IntegrationTestSuite) TearDownTest() { | ||
s.T().Log("tearing down test") | ||
if s.net != nil && s.locked { | ||
s.net.Cleanup() | ||
s.locked = false | ||
} | ||
} | ||
|
||
func (s *IntegrationTestSuite) TearDownSuite() { | ||
s.T().Log("tearing down integration test suite") | ||
} | ||
|
||
func TestIntegrationTestSuite(t *testing.T) { | ||
suite.Run(t, new(IntegrationTestSuite)) | ||
} |
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
Oops, something went wrong.