Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bats tests for container run cmd #581

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/005-container.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@
load helpers
load helpers_tui

@test "container run" {
podman container rm -f $TEST_CONTAINER_NAME || echo done

buysbox_image=$(podman image ls --sort repository --format "{{ .Repository }}" --filter "reference=docker.io/library/busybox")
if [ "${buysbox_image}" == "" ] ; then
podman image pull docker.io/library/busybox
fi

image_index=$(podman image ls --sort repository --noheading | nl -v 1 | grep 'busybox ' | awk '{print $1}')

podman_tui_set_view "containers"
podman_tui_select_container_cmd "run"
podman_tui_send_inputs $TEST_CONTAINER_NAME "Tab" "$TEST_CONTAINER_RUN_CMD" "Tab"
podman_tui_send_inputs "Down"
podman_tui_select_item $image_index
podman_tui_send_inputs "Enter"
podman_tui_send_inputs "Tab" "Tab" "Tab" "Tab" "Space"
podman_tui_send_inputs "Tab" "Tab" "Space"
podman_tui_send_inputs "Tab" "Space"
podman_tui_send_inputs "Tab" "Space"
sleep $TEST_TIMEOUT_LOW
podman_tui_send_inputs "Tab" "Tab" "Tab" "Enter"
sleep $TEST_TIMEOUT_HIGH

cnt_status=$(podman container inspect $TEST_CONTAINER_NAME --format "{{ json .State.Status }}")
assert "$cnt_status" =~ "running" "expected container status to match: running"

podman container stop $TEST_CONTAINER_NAME

run_helper podman container ls --all --filter "name=${TEST_CONTAINER_NAME}$" --noheading
assert "$output" == "" "expected $TEST_CONTAINER_NAME to be removed"
}

@test "container create (privileged, timeout, remove)" {
podman container rm -f $TEST_CONTAINER_NAME || echo done

Expand Down
1 change: 1 addition & 0 deletions test/helpers_tui.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TEST_CONTAINER_WORKDIR="/${TEST_NAME}_workdir"
TEST_CONTAINER_ENV1="key1=value1"
TEST_CONTAINER_ENV2="key2=value2"
TEST_CONTAINER_UMASK="0777"
TEST_CONTAINER_RUN_CMD="/bin/sh"
TEST_LABEL_NAME="test"
TEST_LABEL_VALUE="$TEST_NAME"
TEST_LABEL="${TEST_LABEL_NAME}=${TEST_LABEL_VALUE}"
Expand Down