Return exit code on error, disable in tests

This commit is contained in:
Ethan Frey
2017-06-14 16:51:33 +02:00
parent c5644aad31
commit 0ecb38c6da
2 changed files with 18 additions and 2 deletions

View File

@ -46,6 +46,7 @@ func TestSetupEnv(t *testing.T) {
}
demo.Flags().String("foobar", "", "Some test value from config")
cmd := PrepareBaseCmd(demo, "DEMO", "/qwerty/asdfgh") // some missing dir..
cmd.Exit = func(int) {}
viper.Reset()
args := append([]string{cmd.Use}, tc.args...)
@ -98,6 +99,7 @@ func TestSetupConfig(t *testing.T) {
}
boo.Flags().String("boo", "", "Some test value from config")
cmd := PrepareBaseCmd(boo, "RD", "/qwerty/asdfgh") // some missing dir...
cmd.Exit = func(int) {}
viper.Reset()
args := append([]string{cmd.Use}, tc.args...)
@ -175,6 +177,7 @@ func TestSetupUnmarshal(t *testing.T) {
// from the default config here
marsh.Flags().Int("age", base.Age, "Some test value from config")
cmd := PrepareBaseCmd(marsh, "MR", "/qwerty/asdfgh") // some missing dir...
cmd.Exit = func(int) {}
viper.Reset()
args := append([]string{cmd.Use}, tc.args...)
@ -209,6 +212,7 @@ func TestSetupTrace(t *testing.T) {
},
}
cmd := PrepareBaseCmd(trace, "DBG", "/qwerty/asdfgh") // some missing dir..
cmd.Exit = func(int) {}
viper.Reset()
args := append([]string{cmd.Use}, tc.args...)