From 275ec7c2a00c2cbd9d5b1bc00a6e097236f29851 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 18 May 2015 00:05:44 +0200 Subject: [PATCH] parse_test: test stdin enabled and not variadic arg License: MIT Signed-off-by: Christian Couder --- commands/cli/parse_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/commands/cli/parse_test.go b/commands/cli/parse_test.go index 3e639a0a4..5a1895a3d 100644 --- a/commands/cli/parse_test.go +++ b/commands/cli/parse_test.go @@ -161,6 +161,17 @@ func TestArgumentParsing(t *testing.T) { commands.StringArg("b", true, true, "another arg").EnableStdin(), }, }, + "stdinenablednotvariadic": &commands.Command{ + Arguments: []commands.Argument{ + commands.StringArg("a", true, false, "some arg").EnableStdin(), + }, + }, + "stdinenablednotvariadic2args": &commands.Command{ + Arguments: []commands.Argument{ + commands.StringArg("a", true, false, "some arg"), + commands.StringArg("b", true, false, "another arg").EnableStdin(), + }, + }, }, } @@ -245,4 +256,16 @@ func TestArgumentParsing(t *testing.T) { fstdin = fileToSimulateStdin(t, "stdin1\nstdin2") test([]string{"stdinenabled2args", "value1"}, fstdin, []string{"value1", "stdin1", "stdin2"}) + + test([]string{"stdinenablednotvariadic", "value1"}, nil, []string{"value1"}) + + fstdin = fileToSimulateStdin(t, "stdin1") + test([]string{"stdinenablednotvariadic"}, fstdin, []string{"stdin1"}) + test([]string{"stdinenablednotvariadic", "value1"}, fstdin, []string{"value1"}) + + test([]string{"stdinenablednotvariadic2args", "value1", "value2"}, nil, []string{"value1", "value2"}) + + fstdin = fileToSimulateStdin(t, "stdin1") + test([]string{"stdinenablednotvariadic2args", "value1"}, fstdin, []string{"value1", "stdin1"}) + test([]string{"stdinenablednotvariadic2args", "value1", "value2"}, fstdin, []string{"value1", "value2"}) }