From 3abf892a8aa41371a80892edd6f946e17a627b78 Mon Sep 17 00:00:00 2001 From: Yonghwan SO Date: Tue, 28 Jun 2022 23:35:07 +0900 Subject: [PATCH] fixed typo and added one more test case --- soda/cmd/root_integration_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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",