Skip to content

Commit

Permalink
Merge pull request #581 from navidys/podman_run_test
Browse files Browse the repository at this point in the history
Added bats tests for container run cmd
  • Loading branch information
navidys authored Mar 8, 2025
2 parents 9be037d + 43fbc57 commit a92cec5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
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

0 comments on commit a92cec5

Please sign in to comment.