summaryrefslogtreecommitdiff
path: root/test/system/600-completion.bats
diff options
context:
space:
mode:
Diffstat (limited to 'test/system/600-completion.bats')
-rw-r--r--test/system/600-completion.bats57
1 files changed, 42 insertions, 15 deletions
diff --git a/test/system/600-completion.bats b/test/system/600-completion.bats
index 1e43cdc41..8cac2c9aa 100644
--- a/test/system/600-completion.bats
+++ b/test/system/600-completion.bats
@@ -8,6 +8,17 @@
load helpers
+# Returns true if we are able to podman-pause
+function _can_pause() {
+ # Even though we're just trying completion, not an actual unpause,
+ # podman barfs with:
+ # Error: unpause is not supported for cgroupv1 rootless containers
+ if is_rootless && is_cgroupsv1; then
+ return 1
+ fi
+ return 0
+}
+
function check_shell_completion() {
local count=0
@@ -61,8 +72,9 @@ function check_shell_completion() {
if ! is_remote; then
run_completion "$@" $cmd "--"
# If this fails there is most likely a problem with the cobra library
- is "${lines[0]}" "--.*" "Found flag in suggestions"
- [ ${#lines[@]} -gt 2 ] || die "No flag suggestions"
+ is "${lines[0]}" "--.*" \
+ "$* $cmd: flag(s) listed in suggestions"
+ [ ${#lines[@]} -gt 2 ] || die "$* $cmd: No flag suggestions"
_check_completion_end NoFileComp
fi
# continue the outer for args loop
@@ -70,8 +82,14 @@ function check_shell_completion() {
;;
*CONTAINER*)
+ # podman unpause fails early on rootless cgroupsv1
+ if [[ $cmd = "unpause" ]] && ! _can_pause; then
+ continue 2
+ fi
+
run_completion "$@" $cmd "${extra_args[@]}" ""
- is "$output" ".*-$random_container_name${nl}" "Found expected container in suggestions"
+ is "$output" ".*-$random_container_name${nl}" \
+ "$* $cmd: actual container listed in suggestions"
match=true
# resume
@@ -79,7 +97,8 @@ function check_shell_completion() {
*POD*)
run_completion "$@" $cmd "${extra_args[@]}" ""
- is "$output" ".*-$random_pod_name${nl}" "Found expected pod in suggestions"
+ is "$output" ".*-$random_pod_name${nl}" \
+ "$* $cmd: actual pod listed in suggestions"
_check_completion_end NoFileComp
match=true
@@ -88,16 +107,20 @@ function check_shell_completion() {
*IMAGE*)
run_completion "$@" $cmd "${extra_args[@]}" ""
- is "$output" ".*localhost/$random_image_name:$random_image_tag${nl}" "Found expected image in suggestions"
+ is "$output" ".*localhost/$random_image_name:$random_image_tag${nl}" \
+ "$* $cmd: actual image listed in suggestions"
# check that we complete the image with and without tag after at least one char is typed
run_completion "$@" $cmd "${extra_args[@]}" "${random_image_name:0:1}"
- is "$output" ".*$random_image_name:$random_image_tag${nl}" "Found expected image with tag in suggestions"
- is "$output" ".*$random_image_name${nl}" "Found expected image without tag in suggestions"
+ is "$output" ".*$random_image_name:$random_image_tag${nl}" \
+ "$* $cmd: image name:tag included in suggestions"
+ is "$output" ".*$random_image_name${nl}" \
+ "$* $cmd: image name(w/o tag) included in suggestions"
# check that we complete the image id after at least two chars are typed
run_completion "$@" $cmd "${extra_args[@]}" "${random_image_id:0:2}"
- is "$output" ".*$random_image_id${nl}" "Found expected image id in suggestions"
+ is "$output" ".*$random_image_id${nl}" \
+ "$* $cmd: image id included in suggestions when two leading characters present in command line"
match=true
# resume
@@ -105,7 +128,8 @@ function check_shell_completion() {
*NETWORK*)
run_completion "$@" $cmd "${extra_args[@]}" ""
- is "$output" ".*$random_network_name${nl}" "Found network in suggestions"
+ is "$output" ".*$random_network_name${nl}" \
+ "$* $cmd: actual network listed in suggestions"
_check_completion_end NoFileComp
match=true
@@ -114,7 +138,8 @@ function check_shell_completion() {
*VOLUME*)
run_completion "$@" $cmd "${extra_args[@]}" ""
- is "$output" ".*$random_volume_name${nl}" "Found volume in suggestions"
+ is "$output" ".*$random_volume_name${nl}" \
+ "$* $cmd: actual volume listed in suggestions"
_check_completion_end NoFileComp
match=true
@@ -126,14 +151,14 @@ function check_shell_completion() {
### FIXME how can we get the configured registries?
_check_completion_end NoFileComp
### FIXME this fails if no registries are configured
- [[ ${#lines[@]} -gt 2 ]] || die "No registries found in suggestions"
+ [[ ${#lines[@]} -gt 2 ]] || die "$* $cmd: No REGISTRIES found in suggestions"
match=true
# resume
;;&
*PATH* | *CONTEXT* | *KUBEFILE* | *COMMAND* | *ARG...* | *URI*)
- # default shell completion should be done for everthing which accepts a path
+ # default shell completion should be done for everything which accepts a path
run_completion "$@" $cmd "${extra_args[@]}" ""
# cp is a special case it returns ShellCompDirectiveNoSpace
@@ -141,7 +166,7 @@ function check_shell_completion() {
_check_completion_end NoSpace
else
_check_completion_end Default
- [[ ${#lines[@]} -eq 2 ]] || die "Suggestions are in the output"
+ [[ ${#lines[@]} -eq 2 ]] || die "$* $cmd: Suggestions are in the output"
fi
;;
@@ -172,7 +197,7 @@ function check_shell_completion() {
run_completion "$@" $cmd "${extra_args[@]}" ""
_check_completion_end NoFileComp
if [ ${#lines[@]} -gt 2 ]; then
- # checking for line count is not enough since we may inlcude additional debug output
+ # checking for line count is not enough since we may include additional debug output
# lines starting with [Debug] are allowed
i=0
length=$(( ${#lines[@]} - 2 ))
@@ -212,7 +237,9 @@ function _check_completion_end() {
run_podman create --name created-$random_container_name $IMAGE
run_podman run --name running-$random_container_name -d $IMAGE top
run_podman run --name pause-$random_container_name -d $IMAGE top
- run_podman pause pause-$random_container_name
+ if _can_pause; then
+ run_podman pause pause-$random_container_name
+ fi
run_podman run --name exited-$random_container_name -d $IMAGE echo exited
# create pods for each state