-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
arch_test.go
44 lines (39 loc) · 920 Bytes
/
arch_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
package main
import (
"fmt"
"testing"
"github.com/oalders/is/ops"
"github.com/oalders/is/types"
"github.com/stretchr/testify/assert"
)
func TestArchCmd(t *testing.T) {
t.Parallel()
type ArchTest struct {
Cmd ArchCmd
Error bool
Success bool
}
tests := []ArchTest{
{ArchCmd{ops.Eq, "zzz"}, false, false},
{ArchCmd{ops.Ne, "zzz"}, false, true},
{ArchCmd{ops.In, "amd64,arm,arm64"}, false, true},
{ArchCmd{ops.In, "X"}, false, false},
{ArchCmd{ops.Like, "zzz"}, false, false},
{ArchCmd{ops.Unlike, "zzz"}, false, true},
}
for _, test := range tests {
ctx := types.Context{Debug: false}
err := test.Cmd.Run(&ctx)
name := fmt.Sprintf("%s %s", test.Cmd.Op, test.Cmd.Val)
if test.Error {
assert.Error(t, err, name)
} else {
assert.NoError(t, err, name)
}
if test.Success {
assert.True(t, ctx.Success, name)
} else {
assert.False(t, ctx.Success, name)
}
}
}