From 42629ec5cd20f336a8e94dded1b3d10578a65845 Mon Sep 17 00:00:00 2001 From: Navid Yaghoobi Date: Mon, 4 Mar 2024 22:57:38 +1100 Subject: [PATCH] unit test + e2e test Signed-off-by: Navid Yaghoobi --- .github/workflows/go.yml | 2 -- test/006-container.bats | 16 ++++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 530d40ec..d07c81c1 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -71,9 +71,7 @@ jobs: make .install.bats make binary ./bin/prometheus-podman-exporter --collector.enable-all --collector.store_labels & - echo "starting e2e" make test-e2e - echo "stopping e2e" build_binary: runs-on: ubuntu-latest diff --git a/test/006-container.bats b/test/006-container.bats index af65c6bf..29e22893 100644 --- a/test/006-container.bats +++ b/test/006-container.bats @@ -74,14 +74,14 @@ load helpers exit fi - # podman container create --name $TEST_CNT_LABEL --label label01=value01 $TEST_BUSYBOX_IMAGE - # cnt_id=$(podman container inspect $TEST_CNT_LABEL -f "{{ .Id }}") - - # curl -s $METRICS_URL | grep "podman_container_info{id=\"${cnt_id:0:12}\",image=\"$TEST_BUSYBOX_IMAGE:latest\",label01=\"value01\",name=\"$TEST_CNT_LABEL\",pod_id=\"\",pod_name=\"\",ports=\"\"} 1" - # if [ $? -ne 0 ] ; then - # false - # exit - # fi + podman container create --name $TEST_CNT_LABEL --label label01=value01 $TEST_BUSYBOX_IMAGE + cnt_id=$(podman container inspect $TEST_CNT_LABEL -f "{{ .Id }}") + + curl -s $METRICS_URL | grep "podman_container_info{id=\"${cnt_id:0:12}\",image=\"$TEST_BUSYBOX_IMAGE:latest\",label01=\"value01\",name=\"$TEST_CNT_LABEL\",pod_id=\"\",pod_name=\"\",ports=\"\"} 1" + if [ $? -ne 0 ] ; then + false + exit + fi true }