remove unknown args and added tests

This commit is contained in:
Abhishek 2016-10-21 12:04:01 +05:30
parent d9899b788d
commit 1c3092150f
2 changed files with 10 additions and 0 deletions

View File

@ -74,6 +74,10 @@ func validateFlags(c *cli.Context, opt *kobject.ConvertOptions) {
if len(dabFile) > 0 && len(opt.InputFile) > 0 && opt.InputFile != DefaultComposeFile { 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") 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) { func validateControllers(opt *kobject.ConvertOptions) {

View File

@ -58,4 +58,10 @@ convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mo
# openshift test # 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" 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 exit $EXIT_STATUS