forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdd33aa
commit d694dbe
Showing
3 changed files
with
58 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
package server | ||
|
||
import "testing" | ||
import ( | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/tendermint/tmlibs/log" | ||
|
||
"github.com/cosmos/cosmos-sdk/mock" | ||
) | ||
|
||
// setupViper creates a homedir to run inside, | ||
// and returns a cleanup function to defer | ||
func setupViper() func() { | ||
rootDir, err := ioutil.TempDir("", "mock-sdk-cmd") | ||
if err != nil { | ||
panic(err) // fuck it! | ||
} | ||
viper.Set("home", rootDir) | ||
return func() { | ||
os.RemoveAll(rootDir) | ||
} | ||
} | ||
|
||
func TestInit(t *testing.T) { | ||
defer setupViper()() | ||
|
||
logger := log.NewNopLogger() | ||
cmd := InitCmd(mock.GenInitOptions, logger) | ||
err := cmd.RunE(nil, nil) | ||
require.NoError(t, err) | ||
} |
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 |
---|---|---|
@@ -1,15 +1,36 @@ | ||
package server | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/cosmos-sdk/mock" | ||
"github.com/tendermint/tmlibs/log" | ||
) | ||
|
||
func TestStart(t *testing.T) { | ||
// app, cleanup, err := mock.SetupApp() | ||
// if cleanup != nil { | ||
// defer cleanup() | ||
// } | ||
defer setupViper()() | ||
|
||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)). | ||
With("module", "mock-cmd") | ||
// logger := log.NewNopLogger() | ||
initCmd := InitCmd(mock.GenInitOptions, logger) | ||
err := initCmd.RunE(nil, nil) | ||
require.NoError(t, err) | ||
|
||
// try to start up | ||
// this should hang forever on success.... how to close??? | ||
|
||
rootDir := viper.GetString("home") | ||
app, err := mock.NewApp(logger, rootDir) | ||
require.NoError(t, err) | ||
_ = StartCmd(app, logger) | ||
// startCmd := StartCmd(app, logger) | ||
|
||
// // TODO: test with tendermint | ||
// err = startCmd.RunE(nil, nil) | ||
// require.NoError(t, err) | ||
// // TODO: init and start | ||
} |