diff --git a/cmd/roaring-migrate/main.go b/cmd/roaring-migrate/main.go index 607a5b129..aa78c9b07 100644 --- a/cmd/roaring-migrate/main.go +++ b/cmd/roaring-migrate/main.go @@ -42,6 +42,9 @@ func realMain() int { Short: "convert roaring pilosa backup to rbf", Long: `roaring-migrate uses the pilosa data-dir for each node, and produces a new backup that is able to be restored from utilizing the new pilosa restore tool.`, Run: func(cmd *cobra.Command, args []string) { + if verbose { + glogger.Infof("Version: %v", Version) + } nodes := strings.Split(dataDir, ",") for _, nodePath := range nodes { err := Migrate(nodePath, backupPath, verbose) @@ -66,13 +69,10 @@ func realMain() int { glogger.Errorf("Error setting flag backup-dir") return 1 } - if verbose { - glogger.Infof("Version: %v", Version) - } err = cmdMigrate.Execute() if err != nil { - glogger.Errorf("exec error", err) + glogger.Errorf("exec error %v", err) return 1 } return 0 diff --git a/cmd/roaring-migrate/main_test.go b/cmd/roaring-migrate/main_test.go index 9b1d86d05..8f452c178 100644 --- a/cmd/roaring-migrate/main_test.go +++ b/cmd/roaring-migrate/main_test.go @@ -27,6 +27,12 @@ func TestFileExists(t *testing.T) { } func TestMainProgram(t *testing.T) { + os.Args = []string{"roaring-migrate", + "--verbose", + } + if realMain() == 0 { + t.Fatal("should fail and it succeeded") + } os.Args = []string{"roaring-migrate", "--verbose", } @@ -39,7 +45,7 @@ func TestMainProgram(t *testing.T) { } defer os.RemoveAll(dir) // clean up os.Args = []string{"roaring-migrate", - "--verbose", + "--verbose=true", "--data-dir=testdata/data-dir/", "--backup-dir=" + dir, }