parse_test: test stdin enabled and not variadic arg
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
May 18, 2015 at 00:05 UTC
275ec7c2a00c2cbd9d5b1bc00a6e097236f29851
1 file changed
+23
commands/cli/parse_test.go
+23
@@ -161,6 +161,17 @@ func TestArgumentParsing(t *testing.T) {
161
commands.StringArg("b", true, true, "another arg").EnableStdin(),
162
},
163
},
164
+ "stdinenablednotvariadic": &commands.Command{
165
+ Arguments: []commands.Argument{
166
+ commands.StringArg("a", true, false, "some arg").EnableStdin(),
167
+ },
168
+ },
169
+ "stdinenablednotvariadic2args": &commands.Command{
170
+ Arguments: []commands.Argument{
171
+ commands.StringArg("a", true, false, "some arg"),
172
+ commands.StringArg("b", true, false, "another arg").EnableStdin(),
173
+ },
174
+ },
175
},
176
}
177
@@ -245,4 +256,16 @@ func TestArgumentParsing(t *testing.T) {
256
257
fstdin = fileToSimulateStdin(t, "stdin1\nstdin2")
258
test([]string{"stdinenabled2args", "value1"}, fstdin, []string{"value1", "stdin1", "stdin2"})
259
+
260
+ test([]string{"stdinenablednotvariadic", "value1"}, nil, []string{"value1"})
261
+
262
+ fstdin = fileToSimulateStdin(t, "stdin1")
263
+ test([]string{"stdinenablednotvariadic"}, fstdin, []string{"stdin1"})
264
+ test([]string{"stdinenablednotvariadic", "value1"}, fstdin, []string{"value1"})
265
+
266
+ test([]string{"stdinenablednotvariadic2args", "value1", "value2"}, nil, []string{"value1", "value2"})
267
+
268
+ fstdin = fileToSimulateStdin(t, "stdin1")
269
+ test([]string{"stdinenablednotvariadic2args", "value1"}, fstdin, []string{"value1", "stdin1"})
270
+ test([]string{"stdinenablednotvariadic2args", "value1", "value2"}, fstdin, []string{"value1", "value2"})
271
}