@@ -100,39 +100,61 @@ func TestGenericApplyInputSourceMethodEnvVarSet(t *testing.T) {
100100}
101101
102102func TestStringSliceApplyInputSourceValue_Alias (t * testing.T ) {
103+ dest := cli .NewStringSlice ()
103104 tis := testApplyInputSource {
104- Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" , Aliases : []string {"test_alias" }}),
105+ Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" , Aliases : []string {"test_alias" }, Destination : dest }),
105106 FlagName : "test_alias" ,
106107 MapValue : []interface {}{"hello" , "world" },
107108 }
108109 c := runTest (t , tis )
109110 expect (t , c .StringSlice ("test_alias" ), []string {"hello" , "world" })
111+ expect (t , dest .Value (), []string {"hello" , "world" })
110112
113+ // reset dest
114+ dest = cli .NewStringSlice ()
115+ tis = testApplyInputSource {
116+ Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" , Aliases : []string {"test_alias" }, Destination : dest }),
117+ FlagName : "test_alias" ,
118+ MapValue : []interface {}{"hello" , "world" },
119+ }
111120 c = runRacyTest (t , tis )
112121 refute (t , c .StringSlice ("test_alias" ), []string {"hello" , "world" })
122+ refute (t , dest .Value (), []string {"hello" , "world" })
113123}
114124
115125func TestStringSliceApplyInputSourceValue (t * testing.T ) {
126+ dest := cli .NewStringSlice ()
116127 tis := testApplyInputSource {
117- Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" }),
128+ Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" , Destination : dest }),
118129 FlagName : "test" ,
119130 MapValue : []interface {}{"hello" , "world" },
120131 }
121132 c := runTest (t , tis )
122133 expect (t , c .StringSlice ("test" ), []string {"hello" , "world" })
134+ expect (t , dest .Value (), []string {"hello" , "world" })
123135
136+ // reset dest
137+ dest = cli .NewStringSlice ()
138+ tis = testApplyInputSource {
139+ Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" , Destination : dest }),
140+ FlagName : "test" ,
141+ MapValue : []interface {}{"hello" , "world" },
142+ }
124143 c = runRacyTest (t , tis )
125144 refute (t , c .StringSlice ("test" ), []string {"hello" , "world" })
145+ refute (t , dest .Value (), []string {"hello" , "world" })
126146}
127147
128148func TestStringSliceApplyInputSourceMethodContextSet (t * testing.T ) {
149+ dest := cli .NewStringSlice ()
129150 c := runTest (t , testApplyInputSource {
130- Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" }),
151+ Flag : NewStringSliceFlag (& cli.StringSliceFlag {Name : "test" , Destination : dest }),
131152 FlagName : "test" ,
132153 MapValue : []interface {}{"hello" , "world" },
133154 ContextValueString : "ohno" ,
134155 })
135156 expect (t , c .StringSlice ("test" ), []string {"ohno" })
157+ expect (t , dest .Value (), []string {"ohno" })
136158}
137159
138160func TestStringSliceApplyInputSourceMethodEnvVarSet (t * testing.T ) {
@@ -151,43 +173,73 @@ func TestStringSliceApplyInputSourceMethodEnvVarSet(t *testing.T) {
151173}
152174
153175func TestIntSliceApplyInputSourceValue_Alias (t * testing.T ) {
176+ dest := cli .NewIntSlice ()
154177 tis := testApplyInputSource {
155- Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" , Aliases : []string {"test_alias" }}),
178+ Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" , Aliases : []string {"test_alias" }, Destination : dest }),
156179 FlagName : "test_alias" ,
157180 MapValue : []interface {}{1 , 2 },
158181 }
159182 c := runTest (t , tis )
160183 expect (t , c .IntSlice ("test_alias" ), []int {1 , 2 })
184+ expect (t , dest .Value (), []int {1 , 2 })
161185
186+ dest = cli .NewIntSlice ()
187+ tis = testApplyInputSource {
188+ Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" , Aliases : []string {"test_alias" }, Destination : dest }),
189+ FlagName : "test_alias" ,
190+ MapValue : []interface {}{1 , 2 },
191+ }
162192 c = runRacyTest (t , tis )
163193 refute (t , c .IntSlice ("test_alias" ), []int {1 , 2 })
194+ refute (t , dest .Value (), []int {1 , 2 })
164195}
165196
166197func TestIntSliceApplyInputSourceValue (t * testing.T ) {
198+ dest := cli .NewIntSlice ()
167199 tis := testApplyInputSource {
168- Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" }),
200+ Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" , Destination : dest }),
169201 FlagName : "test" ,
170202 MapValue : []interface {}{1 , 2 },
171203 }
172204 c := runTest (t , tis )
173205 expect (t , c .IntSlice ("test" ), []int {1 , 2 })
206+ expect (t , dest .Value (), []int {1 , 2 })
174207
208+ // reset dest
209+ dest = cli .NewIntSlice ()
210+ tis = testApplyInputSource {
211+ Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" , Destination : dest }),
212+ FlagName : "test" ,
213+ MapValue : []interface {}{1 , 2 },
214+ }
175215 c = runRacyTest (t , tis )
176216 refute (t , c .IntSlice ("test" ), []int {1 , 2 })
217+ refute (t , dest .Value (), []int {1 , 2 })
177218}
178219
179220func TestIntSliceApplyInputSourceMethodContextSet (t * testing.T ) {
221+ dest := cli .NewIntSlice ()
180222 tis := testApplyInputSource {
181- Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" }),
223+ Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" , Destination : dest }),
182224 FlagName : "test" ,
183225 MapValue : []interface {}{1 , 2 },
184226 ContextValueString : "3" ,
185227 }
186228 c := runTest (t , tis )
187229 expect (t , c .IntSlice ("test" ), []int {3 })
230+ expect (t , dest .Value (), []int {3 })
188231
232+ // reset dest
233+ dest = cli .NewIntSlice ()
234+ tis = testApplyInputSource {
235+ Flag : NewIntSliceFlag (& cli.IntSliceFlag {Name : "test" , Destination : dest }),
236+ FlagName : "test" ,
237+ MapValue : []interface {}{1 , 2 },
238+ ContextValueString : "3" ,
239+ }
189240 c = runRacyTest (t , tis )
190241 refute (t , c .IntSlice ("test" ), []int {3 })
242+ refute (t , dest .Value (), []int {3 })
191243}
192244
193245func TestIntSliceApplyInputSourceMethodEnvVarSet (t * testing.T ) {
0 commit comments