Skip to content

Commit 208c117

Browse files
committed
test: add coverage for ADDITIONAL_PACKAGES and TAIL_FTL_LOG
- Add CONTAINER_PACKAGES shared container (ADDITIONAL_PACKAGES=wget) and a test that verifies the package is installed and on PATH - Add inline container test for TAIL_FTL_LOG=true, verifying that FTL log lines tagged [FTL] appear in docker logs output Signed-off-by: Adam Warner <adam@adwarner.co.uk> Signed-off-by: Adam Warner <me@adamwarner.co.uk>
1 parent f26f789 commit 208c117

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

test/run.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ CONTAINER_CUSTOM=$(start_container \
5353
-e FTLCONF_webserver_api_password=1234567890 \
5454
-e FTLCONF_webserver_port=8080 \
5555
-e FTLCONF_dns_upstreams="8.8.8.8;1.1.1.1")
56+
CONTAINER_PACKAGES=$(start_container \
57+
-e ADDITIONAL_PACKAGES=wget)
5658

57-
export CONTAINER_DEFAULT CONTAINER_CUSTOM CIPLATFORM
59+
export CONTAINER_DEFAULT CONTAINER_CUSTOM CONTAINER_PACKAGES CIPLATFORM
5860

5961
# ---- Wait for containers to be ready ----------------------------------------
6062

@@ -76,7 +78,7 @@ wait_for_ftl() {
7678
echo "ready (${elapsed}s)"
7779
}
7880

79-
for container in "$CONTAINER_DEFAULT" "$CONTAINER_CUSTOM"; do
81+
for container in "$CONTAINER_DEFAULT" "$CONTAINER_CUSTOM" "$CONTAINER_PACKAGES"; do
8082
wait_for_ftl "$container"
8183
done
8284

test/test_suite.bats

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
}
6363

6464

65+
# ---- Additional packages ----------------------------------------------------
66+
67+
@test "ADDITIONAL_PACKAGES are installed" {
68+
run docker exec "$CONTAINER_PACKAGES" which wget
69+
[ "$status" -eq 0 ]
70+
}
71+
6572
# ---- Container configuration ------------------------------------------------
6673

6774
@test "Cron file is valid" {
@@ -94,3 +101,34 @@
94101
[ "$status" -eq 0 ]
95102
[[ "$output" == *"Assigning password defined by Environment Variable"* ]]
96103
}
104+
105+
# ---- TAIL_FTL_LOG -----------------------------------------------------------
106+
107+
@test "TAIL_FTL_LOG causes FTL log lines to appear in docker logs" {
108+
local platform_args=()
109+
[ -n "${CIPLATFORM:-}" ] && platform_args=(--platform "$CIPLATFORM")
110+
111+
local container
112+
container=$(docker run -d -t "${platform_args[@]}" \
113+
-e TZ="Europe/London" \
114+
-e TAIL_FTL_LOG=true \
115+
pihole:test)
116+
117+
local timeout=60
118+
local elapsed=0
119+
until docker logs "$container" 2>&1 | grep -q "########## FTL started"; do
120+
sleep 1
121+
elapsed=$(( elapsed + 1 ))
122+
if (( elapsed >= timeout )); then
123+
docker rm -f "$container"
124+
echo "FTL did not start within ${timeout}s"
125+
return 1
126+
fi
127+
done
128+
129+
run docker logs "$container"
130+
docker rm -f "$container"
131+
132+
[ "$status" -eq 0 ]
133+
[[ "$output" == *"[FTL]"* ]]
134+
}

0 commit comments

Comments
 (0)