Add a partial test for geoip (#902)

This commit is contained in:
Chad Whitacre 2021-03-26 16:57:21 -04:00 committed by GitHub
parent a868b09044
commit 88f90e046e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 10 deletions

View File

@ -44,6 +44,7 @@ jobs:
run: |
./create-docker-volumes-test.sh
./relay-credentials-test.sh
./geoip-test.sh
- name: Inspect failure
if: failure()

View File

@ -14,19 +14,17 @@ teardown() {
}
setup() {
# Clone the local repo into a temp dir, and propagate local changes.
# FWIW `git clone --local` breaks for me because it depends on hard-linking,
# which doesn't work across devices, and I happen to have my workspace and
# tmp on separate devices.
# Clone the local repo into a temp dir. FWIW `git clone --local` breaks for
# me because it depends on hard-linking, which doesn't work across devices,
# and I happen to have my workspace and /tmp on separate devices.
git clone --depth=1 "file://$(pwd)" "$_SANDBOX"
# Now propagate any local changes from the working copy to the sandbox. This
# provides a pretty nice dev experience: edit the files in the working copy,
# then run `DEBUG=1 some-test.sh` to leave the sandbox up for interactive
# dev/debugging.
git status --porcelain | while read line; do
# $line here is something like `M some-script.sh`. By propagating working
# copy changes to the sandbox, we can provide a pretty nice dev experience:
# edit the files in the working copy, then run `DEBUG=1 some-test.sh` to
# leave the sandbox up for interactive dev/debugging.
# $line here is something like `M some-script.sh`.
local filepath="$(cut -f2 -d' ' <(echo $line))"
local filestatus="$(cut -f1 -d' ' <(echo $line))"

16
install/geoip-test.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
source "$(dirname $0)/_test_setup.sh"
mmdb="geoip/GeoLite2-City.mmdb"
# Starts with no mmdb, ends up with empty.
test ! -f $mmdb
./install/geoip.sh
diff -rub $mmdb $mmdb.empty
# Doesn't clobber existing, though.
echo GARBAGE > $mmdb
./install/geoip.sh
test "$(cat $mmdb)" = "GARBAGE"
report_success