-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·61 lines (51 loc) · 1.48 KB
/
test.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -e
# Check if a test script was provided
if [ -z "$1" ]; then
echo "Usage: $0 <test_script|all>"
echo "Example: $0 tests/test_pg_cron.sh"
echo "Example: $0 all"
exit 1
fi
TEST_SCRIPT=$1
if [ "$TEST_SCRIPT" = "all" ]; then
shopt -s nullglob
TEST_FILES=(tests/test_*.sh)
shopt -u nullglob
if [ ${#TEST_FILES[@]} -eq 0 ]; then
echo "No test files found under tests/test_*.sh"
exit 1
fi
else
if [ ! -f "$TEST_SCRIPT" ]; then
echo "Test script $TEST_SCRIPT not found!"
exit 1
fi
TEST_FILES=("$TEST_SCRIPT")
fi
# Default versions (matching the workflow defaults)
PG_VERSION=${PG_VERSION:-15}
POSTGIS_VERSION=${POSTGIS_VERSION:-3.5}
HLL_VERSION=${HLL_VERSION:-2.18}
# Function to clean up
cleanup() {
echo "Cleaning up..."
docker rmi -f postgres-cloudsql-docker:test >/dev/null 2>&1 || true
docker rm -f postgres-test >/dev/null 2>&1 || true
}
# Ensure cleanup happens even on error
trap cleanup EXIT
echo "Building test image..."
docker build \
--platform=${DOCKER_BUILD_PLATFORM:-linux/amd64} \
--build-arg PG_VERSION=${PG_VERSION} \
--build-arg POSTGIS_VERSION=${POSTGIS_VERSION} \
--build-arg HLL_VERSION=${HLL_VERSION} \
-t postgres-cloudsql-docker:test .
# Make the test scripts executable
chmod +x "${TEST_FILES[@]}"
for test_file in "${TEST_FILES[@]}"; do
echo "Running test: $test_file"
"./$test_file"
done
# The cleanup will happen automatically due to the trap