Skip to content

Commit

Permalink
System tests: confirm that -a and -l clash
Browse files Browse the repository at this point in the history
...and fix one instance where there was no check

Signed-off-by: Ed Santiago <[email protected]>
  • Loading branch information
edsantiago authored and mheon committed Nov 12, 2021
1 parent c3f3e6d commit f8ede7c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cmd/podman/containers/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func validateStart(cmd *cobra.Command, args []string) error {
if len(args) == 0 && !startOptions.Latest && !startOptions.All {
return errors.New("start requires at least one argument")
}
if startOptions.All && startOptions.Latest {
return errors.Errorf("--all and --latest cannot be used together")
}
if len(args) > 0 && startOptions.Latest {
return errors.Errorf("--latest and containers cannot be used together")
}
Expand Down
6 changes: 6 additions & 0 deletions test/system/015-help.bats
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ function check_help() {
run_podman 125 "$@" $cmd -l nonexistent-container
is "$output" "Error: .*--latest and \(containers\|pods\|arguments\) cannot be used together" \
"'$command_string' with both -l and container"

# Combine -l and -a, too (but spell it as --all, because "-a"
# means "attach" in podman container start)
run_podman 125 "$@" $cmd --all --latest
is "$output" "Error: \(--all and --latest cannot be used together\|--all, --latest and containers cannot be used together\|--all, --latest and arguments cannot be used together\|unknown flag\)" \
"'$command_string' with both --all and --latest"
fi
fi

Expand Down
4 changes: 0 additions & 4 deletions test/system/045-start.bats
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ load helpers
expected="Error: either start all containers or the container(s) provided in the arguments"
run_podman 125 start --all 12333
is "$output" "$expected" "start --all, with args, throws error"
if ! is_remote; then
run_podman 125 start --all --latest
is "$output" "$expected" "podman start --all --latest"
fi
}

@test "podman start --filter - start only containers that match the filter" {
Expand Down

0 comments on commit f8ede7c

Please sign in to comment.