diff --git a/soda/cmd/root_integration_test.go b/soda/cmd/root_integration_test.go index 935daf69..70291a18 100644 --- a/soda/cmd/root_integration_test.go +++ b/soda/cmd/root_integration_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" ) -func Test_RootCmd_Environtment(t *testing.T) { +func Test_RootCmd_Environment(t *testing.T) { oldEnv := os.Getenv("GO_ENV") defer os.Setenv("GO_ENV", oldEnv) @@ -27,6 +27,18 @@ func Test_RootCmd_Environtment(t *testing.T) { r.NoError(err) r.Equal("test", env) + // CLI flag priority: the preferred order of flags and commands + c.SetArgs([]string{ + "--env", + "production", + "help", + }) + os.Setenv("GO_ENV", "test") + err = c.Execute() + r.NoError(err) + r.Equal("production", env) + + // the following order works fine now but need to be considered again // CLI flag priority c.SetArgs([]string{ "help",