@@ -80,31 +80,48 @@ func TestCustom_GetFiles(t *testing.T) {
8080}
8181
8282func TestCustom_CommandNameAndArgs (t * testing.T ) {
83- custom , err := NewCustom (RunnerConfig {
84- TestCommand : "bin/test -- {{testExamples}}" ,
85- TestFilePattern : "tests/**/test_*.sh" ,
86- })
87-
88- if err != nil {
89- t .Fatalf ("Failed to create Custom runner: %v" , err )
90- }
91-
9283 testCases := []string {"tests/test_a.sh" , "tests/test_b.sh" }
9384
94- gotName , gotArgs , err := custom .commandNameAndArgs (custom .TestCommand , testCases )
95- if err != nil {
96- t .Errorf ("Custom.cmdNameAndArgs() error = %v" , err )
97- }
85+ commands := []struct {
86+ command string
87+ wantName string
88+ wantArgs []string
89+ }{
90+ {
91+ command : "bin/test -- {{testExamples}}" ,
92+ wantName : "bin/test" ,
93+ wantArgs : []string {"--" , "tests/test_a.sh" , "tests/test_b.sh" },
94+ },
95+ {
96+ command : "rake test TEST_FILES='{{testExamples}}'" ,
97+ wantName : "rake" ,
98+ wantArgs : []string {"test" , "TEST_FILES=tests/test_a.sh tests/test_b.sh" },
99+ },
100+ }
101+
102+ for _ , tc := range commands {
103+
104+ custom , err := NewCustom (RunnerConfig {
105+ TestCommand : tc .command ,
106+ TestFilePattern : "tests/**/test_*.sh" ,
107+ })
98108
99- wantName := "bin/test"
100- wantArgs := []string {"--" , "tests/test_a.sh" , "tests/test_b.sh" }
109+ if err != nil {
110+ t .Fatalf ("Failed to create Custom runner: %v" , err )
111+ }
101112
102- if gotName != wantName {
103- t .Errorf ("Custom.cmdNameAndArgs() name = %v, want %v" , gotName , wantName )
104- }
113+ gotName , gotArgs , err := custom .commandNameAndArgs (custom .TestCommand , testCases )
114+ if err != nil {
115+ t .Errorf ("Custom.cmdNameAndArgs(%q, testCases) error = %v" , tc .command , err )
116+ }
117+
118+ if gotName != tc .wantName {
119+ t .Errorf ("Custom.cmdNameAndArgs(%q, testCases) name = %v, want %v" , tc .command , gotName , tc .wantName )
120+ }
105121
106- if diff := cmp .Diff (gotArgs , wantArgs ); diff != "" {
107- t .Errorf ("Custom.cmdNameAndArgs() args diff (-got +want):\n %s" , diff )
122+ if diff := cmp .Diff (gotArgs , tc .wantArgs ); diff != "" {
123+ t .Errorf ("Custom.cmdNameAndArgs(%q, testCases) args diff (-got +want):\n %s" , tc .command , diff )
124+ }
108125 }
109126}
110127
0 commit comments