From 1c3092150fa58ebfcbbfb4b9a042d2bd34b80583 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 21 Oct 2016 12:04:01 +0530 Subject: [PATCH] remove unknown args and added tests --- cli/app/app.go | 4 ++++ script/test/cmd/tests.sh | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/cli/app/app.go b/cli/app/app.go index 0ddc551fa..abb7a9b49 100644 --- a/cli/app/app.go +++ b/cli/app/app.go @@ -74,6 +74,10 @@ func validateFlags(c *cli.Context, opt *kobject.ConvertOptions) { if len(dabFile) > 0 && len(opt.InputFile) > 0 && opt.InputFile != DefaultComposeFile { logrus.Fatalf("Error: 'compose' file and 'dab' file cannot be specified at the same time") } + + if len(c.Args()) != 0 { + logrus.Fatal("Unknown Argument(s): ", strings.Join(c.Args(), ",")) + } } func validateControllers(opt *kobject.ConvertOptions) { diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index 695a1f676..c0de9101a 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -58,4 +58,10 @@ convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mo # openshift test convert::expect_success "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/output-os.json" +###### +# Tests related to unknown arguments with cli commands +convert::expect_failure "kompose up $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml" "Unknown Argument docker-gitlab.yml" +convert::expect_failure "kompose down $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml" "Unknown Argument docker-gitlab.yml" +convert::expect_failure "kompose convert $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml" "Unknown Argument docker-gitlab.yml" + exit $EXIT_STATUS