-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequiredFlags_test.go
91 lines (59 loc) · 1.97 KB
/
requiredFlags_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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"testing"
. "github.com/franela/goblin"
)
func Test_RequiredFlags(t *testing.T) {
g := Goblin(t)
g.Describe("Required Flags", func() {
g.It("should throw an error if the path flag was not set", func() {
flag := ""
pathArgument := ""
expected := "The \"path\" flag must be set"
_, err := checkRequiredFlags(pathArgument, flag)
actual := err.Error()
g.Assert(actual).Equal(expected)
})
g.It("should set error to nil if the path flag was set", func() {
path := "./projects"
pathArgument := ""
_, actual := checkRequiredFlags(pathArgument, path)
g.Assert(actual).Equal(nil)
})
g.It("should set error to nil if the path argument is passed in", func() {
path := ""
pathArgument := "./projects"
_, actual := checkRequiredFlags(pathArgument, path)
g.Assert(actual).Equal(nil)
})
g.It("should set the pathDirectory to the pathArgument that was passed in", func() {
path := ""
pathArgument := "./projects"
expected := pathArgument
actual, _ := checkRequiredFlags(pathArgument, path)
g.Assert(actual).Equal(expected)
})
g.It("should set the pathDirectory to the path that was passed in", func() {
path := "./projects"
pathArgument := ""
expected := path
actual, _ := checkRequiredFlags(pathArgument, path)
g.Assert(actual).Equal(expected)
})
g.It("should set the pathDirectory to the path that was passed in if it matches pathArgument", func() {
path := "./projects"
pathArgument := "./projects"
expected := path
actual, _ := checkRequiredFlags(pathArgument, path)
g.Assert(actual).Equal(expected)
})
g.It("should throw an error if the path and pathArgument are passed in but they're different values", func() {
path := "./projects"
pathArgument := "./projects/oshalygin"
expected := "Cannot set a path flag AND an argument"
_, err := checkRequiredFlags(pathArgument, path)
actual := err.Error()
g.Assert(actual).Equal(expected)
})
})
}