forked from apenella/go-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmockExecute_test.go
45 lines (40 loc) · 872 Bytes
/
mockExecute_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package ansibler
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMockExecute(t *testing.T) {
tests := []struct {
desc string
err error
execute *MockExecute
command []string
prefix string
res string
}{
{
desc: "Testing a dummy error",
err: errors.New("(MockExecute::Execute) error"),
execute: &MockExecute{},
command: []string{"error"},
prefix: "",
res: "",
},
{
desc: "Testing an execution",
err: nil,
execute: &MockExecute{},
command: []string{"command", "arg1", "arg2"},
prefix: "prefix",
res: "prefix command arg1 arg2",
},
}
for _, test := range tests {
t.Log(test.desc)
err := test.execute.Execute(test.command[0], test.command[1:], test.prefix)
if err != nil && assert.Error(t, err) {
assert.Equal(t, test.err, err)
}
}
}