cosmos-sdk/tools/confix/cmd/migrate_test.go
Cosmos SDK 8f0d5b15f0
chore: typos fixes by cosmos-sdk bot (#18689)
Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2023-12-11 13:03:19 +00:00

40 lines
1.6 KiB
Go

package cmd_test
import (
"path/filepath"
"strings"
"testing"
"gotest.tools/v3/assert"
"cosmossdk.io/tools/confix/cmd"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
)
func TestMigrateCmd(t *testing.T) {
clientCtx, cleanup := initClientContext(t)
defer cleanup()
_, err := clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.0"})
assert.ErrorContains(t, err, "unknown version")
// clientCtx does not create app.toml, so this should fail
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.45"})
assert.ErrorContains(t, err, "no such file or directory")
// try to migrate from unsupported.toml it should fail without --skip-validate
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.46", filepath.Join(clientCtx.HomeDir, "config", "unsupported.toml")})
assert.ErrorContains(t, err, "failed to migrate config")
// try to migrate from unsupported.toml - it should work and give us a big diff
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.46", filepath.Join(clientCtx.HomeDir, "config", "unsupported.toml"), "--skip-validate", "--verbose"})
assert.NilError(t, err)
assert.Assert(t, strings.Contains(out.String(), "add app-db-backend key"))
// this should work
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.51", filepath.Join(clientCtx.HomeDir, "config", "client.toml"), "--client", "--verbose"})
assert.NilError(t, err)
assert.Assert(t, strings.Contains(out.String(), "add keyring-default-keyname key"))
}