forked from sachaos/viddy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargs_test.go
54 lines (51 loc) · 1.02 KB
/
args_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
46
47
48
49
50
51
52
53
54
package main
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func Test_parseArguments(t *testing.T) {
testCases := []struct {
name string
args []string
exp *Arguments
expErr error
}{
{
name: "-n 2s ls -l",
args: []string{"-n", "2s", "ls", "-l"},
exp: &Arguments{
interval: 2 * time.Second,
isPrecise: false,
isClockwork: false,
cmd: "ls",
args: []string{"-l"},
},
},
{
name: "-n 1 ls -l",
args: []string{"-n", "1", "ls", "-l"},
exp: &Arguments{
interval: 1 * time.Second,
isPrecise: false,
isClockwork: false,
cmd: "ls",
args: []string{"-l"},
},
},
{
name: "invalid interval",
args: []string{"-n", "1ms", "ls", "-l"},
exp: nil,
expErr: IntervalTooSmall,
},
}
for _, tt := range testCases {
tt := tt
t.Run(tt.name, func(t *testing.T) {
argument, err := parseArguments(tt.args)
assert.Equal(t, tt.expErr, err)
assert.Equal(t, tt.exp, argument)
})
}
}