@@ -3,7 +3,6 @@ package cobrakai_test
33import (
44 "context"
55 "fmt"
6- "os"
76 "testing"
87
98 ck "github.com/bep/cobrakai"
@@ -19,7 +18,6 @@ func TestCobraKai(t *testing.T) {
1918 fooBazCommand = & testComand2 {name : "foo_baz" }
2019 )
2120
22- os .Args = []string {"hugo" , "foo" , "--localFlagName" , "foo_local" , "--persistentFlagName" , "foo_persistent" }
2321 c := qt .New (t )
2422 r , err := ck .R (
2523 & testComand1 {name : "hugo" },
@@ -33,17 +31,18 @@ func TestCobraKai(t *testing.T) {
3331 // This can be anything, just used to make sure the same context is passed all the way.
3432 type key string
3533 ctx := context .WithValue (context .Background (), key ("foo" ), "bar" )
36- cdeer , err := r .Execute (ctx )
34+ args := []string {"foo" , "--localFlagName" , "foo_local" , "--persistentFlagName" , "foo_persistent" }
35+ cdeer , err := r .Execute (ctx , args )
3736 c .Assert (err , qt .IsNil )
3837 c .Assert (cdeer .Command .Name (), qt .Equals , "foo" )
3938 tc := cdeer .Command .(* testComand1 )
4039 c .Assert (tc .ctx , qt .Equals , ctx )
4140 c .Assert (tc .localFlagName , qt .Equals , "foo_local" )
4241 c .Assert (tc .persistentFlagName , qt .Equals , "foo_persistent" )
4342
44- os . Args = []string {"hugo" , "foo" , "foo_baz" , "--localFlagName" , "foo_local2" , "--persistentFlagName" , "foo_persistent2" }
43+ args = []string {"foo" , "foo_baz" , "--localFlagName" , "foo_local2" , "--persistentFlagName" , "foo_persistent2" }
4544 ctx = context .WithValue (context .Background (), key ("bar" ), "baz" )
46- cdeer2 , err := r .Execute (ctx )
45+ cdeer2 , err := r .Execute (ctx , args )
4746 c .Assert (err , qt .IsNil )
4847 c .Assert (cdeer2 .Command .Name (), qt .Equals , "foo_baz" )
4948 tc2 := cdeer2 .Command .(* testComand2 )
0 commit comments