-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathargs_test.go
70 lines (63 loc) · 1.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"testing"
)
func TestArgs(t *testing.T) {
t.Run("[test 1] should pass", func(t *testing.T) {
args := &Args{
Files: []string{"test1.csv", "test2.csv"},
Delim: ",",
Pad: 2,
}
err := args.ValidateAll()
if err != nil {
t.Errorf(err.Error())
t.Errorf("Input Args: %+v\n", args)
}
})
t.Run("[test 2] should pass", func(t *testing.T) {
args := &Args{
Files: []string{"test1.csv"},
Delim: ";",
Pad: 5,
}
err := args.ValidateAll()
if err != nil {
t.Errorf(err.Error())
t.Errorf("Input Args: %+v\n", args)
}
})
t.Run("[test 3] should fail (lack of filename)", func(t *testing.T) {
args := &Args{
Files: []string{},
Delim: ";",
Pad: 2,
}
err := args.ValidateAll()
if err == nil {
t.Errorf("Input Args: %+v\n", args)
}
})
t.Run("[test 4] should fail (invalid delimiter)", func(t *testing.T) {
args := &Args{
Files: []string{"test.csv"},
Delim: "!",
Pad: 2,
}
err := args.ValidateAll()
if err == nil {
t.Errorf("Input Args: %+v\n", args)
}
})
t.Run("[test 5] should fail (negative padding value)", func(t *testing.T) {
args := &Args{
Files: []string{"test.csv"},
Delim: ",",
Pad: -1,
}
err := args.ValidateAll()
if err == nil {
t.Errorf("Input Args: %+v\n", args)
}
})
}