11package figtree
22
33import (
4- "github.com/stretchr/testify/assert "
4+ "os "
55 "testing"
6+
7+ "github.com/stretchr/testify/assert"
68)
79
810func TestTree_ListValues (t * testing.T ) {
@@ -11,3 +13,28 @@ func TestTree_ListValues(t *testing.T) {
1113 assert .NoError (t , figs .Parse ())
1214 assert .Contains (t , * figs .List (t .Name ()), "yahuah" )
1315}
16+
17+ func TestListFlag_Set (t * testing.T ) {
18+ t .Run ("PolicyListAppend_TRUE" , func (t * testing.T ) {
19+ PolicyListAppend = true
20+ os .Args = []string {os .Args [0 ], "-x" , "yahuah" }
21+ figs := With (Options {Germinate : true })
22+ figs .NewList ("x" , []string {"bum" }, "Name List" )
23+ assert .NoError (t , figs .Parse ())
24+ assert .Equal (t , "" , figs .Fig ("x" ).ToString ())
25+ assert .Contains (t , * figs .List ("x" ), "yahuah" )
26+ assert .Contains (t , * figs .List ("x" ), "bum" ) // Contains because of PolicyListAppend
27+ os .Args = []string {os .Args [0 ]}
28+ })
29+ t .Run ("PolicyListAppend_DEFAULT" , func (t * testing.T ) {
30+ PolicyListAppend = false
31+ os .Args = []string {os .Args [0 ], "-x" , "yahuah" }
32+ figs := With (Options {Germinate : true })
33+ figs .NewList ("x" , []string {"bum" }, "Name List" )
34+ assert .NoError (t , figs .Parse ())
35+ assert .Equal (t , "" , figs .Fig ("x" ).ToString ())
36+ assert .Contains (t , * figs .List ("x" ), "yahuah" )
37+ assert .NotContains (t , * figs .List ("x" ), "bum" ) // NotContains because of PolicyListAppend
38+ os .Args = []string {os .Args [0 ]}
39+ })
40+ }
0 commit comments