Skip to content

Commit

Permalink
Add more shell exececutor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Suderman committed Apr 25, 2022
1 parent a5c494b commit 558a437
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkg/course/shellSecrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,50 @@ func Test_executor_Get(t *testing.T) {
})
}
}

func Test_newShellExecutor(t *testing.T) {
type args struct {
script []string
}
tests := []struct {
name string
args args
want *executor
wantErr bool
}{
{
name: "basic",
args: args{[]string{"echo", "-n", "hello"}},
want: &executor{
Executable: "/bin/echo",
Args: []string{"-n", "hello"},
},
wantErr: false,
},
{
name: "no args",
args: args{[]string{"echo"}},
want: &executor{
Executable: "/bin/echo",
Args: []string{},
},
wantErr: false,
},
{
name: "no args",
args: args{[]string{"farglebargleshouldreallynotbeanexecutable"}},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := newShellExecutor(tt.args.script)
if tt.wantErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.EqualValues(t, tt.want, got)
}
})
}
}

0 comments on commit 558a437

Please sign in to comment.