From 43fbc57357c8856c9f12fdeb732644e7d02bfa92 Mon Sep 17 00:00:00 2001 From: Navid Yaghoobi Date: Sat, 8 Mar 2025 17:40:57 +1100 Subject: [PATCH] Added bats tests for container run cmd Signed-off-by: Navid Yaghoobi --- test/005-container.bats | 33 +++++++++++++++++++++++++++++++++ test/helpers_tui.bash | 1 + 2 files changed, 34 insertions(+) diff --git a/test/005-container.bats b/test/005-container.bats index a9e15e98..c1889bd2 100644 --- a/test/005-container.bats +++ b/test/005-container.bats @@ -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 diff --git a/test/helpers_tui.bash b/test/helpers_tui.bash index 329587c0..4520c992 100644 --- a/test/helpers_tui.bash +++ b/test/helpers_tui.bash @@ -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}"