@cryptotaxi247 / kubo / commits / c93d583f0

parse_test: add tests with 2 args and stdin

License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>

Christian Couder committed May 17, 2015 at 23:48 UTC c93d583f02f4b4771b7a4587fe869b7ffbbb8254
1 file changed +16 -1
commands/cli/parse_test.go
+16 -1
@@ -155,6 +155,12 @@ func TestArgumentParsing(t *testing.T) {
155 commands.StringArg("a", true, true, "some arg").EnableStdin(),
156 },
157 },
158 + "stdinenabled2args": &commands.Command{
159 + Arguments: []commands.Argument{
160 + commands.StringArg("a", true, false, "some arg"),
161 + commands.StringArg("b", true, true, "another arg").EnableStdin(),
162 + },
163 + },
164 },
165 }
166
@@ -220,7 +226,6 @@ func TestArgumentParsing(t *testing.T) {
226 test([]string{"stdinenabled", "value1", "value2"}, nil, []string{"value1", "value2"})
227
228 fstdin := fileToSimulateStdin(t, "stdin1")
223 -
229 test([]string{"stdinenabled"}, fstdin, []string{"stdin1"})
230 test([]string{"stdinenabled", "value1"}, fstdin, []string{"value1"})
231 test([]string{"stdinenabled", "value1", "value2"}, fstdin, []string{"value1", "value2"})
@@ -230,4 +235,14 @@ func TestArgumentParsing(t *testing.T) {
235
236 fstdin = fileToSimulateStdin(t, "stdin1\nstdin2\nstdin3")
237 test([]string{"stdinenabled"}, fstdin, []string{"stdin1", "stdin2", "stdin3"})
238 +
239 + test([]string{"stdinenabled2args", "value1", "value2"}, nil, []string{"value1", "value2"})
240 +
241 + fstdin = fileToSimulateStdin(t, "stdin1")
242 + test([]string{"stdinenabled2args", "value1"}, fstdin, []string{"value1", "stdin1"})
243 + test([]string{"stdinenabled2args", "value1", "value2"}, fstdin, []string{"value1", "value2"})
244 + test([]string{"stdinenabled2args", "value1", "value2", "value3"}, fstdin, []string{"value1", "value2", "value3"})
245 +
246 + fstdin = fileToSimulateStdin(t, "stdin1\nstdin2")
247 + test([]string{"stdinenabled2args", "value1"}, fstdin, []string{"value1", "stdin1", "stdin2"})
248 }