-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlist_flag_test.go
More file actions
41 lines (37 loc) · 1.3 KB
/
list_flag_test.go
File metadata and controls
41 lines (37 loc) · 1.3 KB
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
package figtree
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTree_ListValues(t *testing.T) {
figs := With(Options{Germinate: true})
figs.NewList(t.Name(), []string{"yahuah"}, "Name List")
assert.NoError(t, figs.Parse())
assert.Contains(t, *figs.List(t.Name()), "yahuah")
}
func TestListFlag_Set(t *testing.T) {
t.Run("PolicyListAppend_TRUE", func(t *testing.T) {
PolicyListAppend = true
defer func() { PolicyListAppend = false }()
os.Args = []string{os.Args[0], "-x", "yeshua"}
figs := With(Options{Germinate: true})
figs.NewList("x", []string{"bum"}, "Name List")
assert.NoError(t, figs.Parse())
assert.Equal(t, "bum,yeshua", figs.FigFlesh("x").ToString())
assert.Contains(t, *figs.List("x"), "yeshua")
assert.Contains(t, *figs.List("x"), "bum")
os.Args = []string{os.Args[0]}
})
t.Run("PolicyListAppend_DEFAULT", func(t *testing.T) {
PolicyListAppend = false
os.Args = []string{os.Args[0], "-x", "yahuah"}
figs := With(Options{Germinate: true})
figs.NewList("x", []string{"bum"}, "Name List")
assert.NoError(t, figs.Parse())
assert.Equal(t, "yahuah", figs.FigFlesh("x").ToString())
assert.Contains(t, *figs.List("x"), "yahuah")
assert.NotContains(t, *figs.List("x"), "bum") // NotContains because of PolicyListAppend
os.Args = []string{os.Args[0]}
})
}