-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·55 lines (45 loc) · 1.06 KB
/
test.sh
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
#!/usr/bin/env bash
passcount=0
failcount=0
# runcount=0
# testtotal=$(grep -c '^tf ' "$0")
dbname="postgres"
# Wait for database
while ! pg_isready -q -U postgres -d $dbname; do
echo "Waiting for database..."
sleep 1
done
psqld="psql -AtqX -U postgres -d $dbname"
# Create schemas
sqldir=/sql
for f in $(find $sqldir -name '*.sql'); do
echo "Applying SQL file $f"
$psqld -f $f
done
function run-test() {
name=$1
sql=$2
res=$3
echo "Running test $name"
echo "> $sql"
out=$($psqld -c "$sql")
echo -n "--> ${out:-"null"}"
if [[ "$out" == "$res" ]]; then
echo " == ${res:-null}"
echo "$name: pass"
((passcount++))
else
echo " != ${res:-null}"
echo "$name: fail"
((failcount++))
fi
echo ""
}
echo -e "\n\nRunning tests..."
run-test "cluster_expansion_zoom" \
"SELECT tile_utils.cluster_expansion_zoom('MULTIPOINT(40 40, 20 21)', 10)" \
14
run-test "cluster_expansion_zoom (single point)" \
"SELECT tile_utils.cluster_expansion_zoom('POINT(40 40)', 10)" \
""
echo "$passcount tests passed, $failcount tests failed"