From 43ae5113e8a651579a3e64eb76584fe500e241df Mon Sep 17 00:00:00 2001 From: Paul Tyng Date: Fri, 10 Jan 2020 11:19:45 -0500 Subject: [PATCH] Add testing to controller script --- .gitattributes | 5 ++++- .github/workflows/go.yml | 2 +- controller.sh | 47 ++++++++++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/.gitattributes b/.gitattributes index f45cdca..25f310c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,9 @@ * text=auto +*.go diff=golang + +*.sh eol=lf + *.jar binary *.wt binary *.bson binary @@ -11,4 +15,3 @@ WiredTiger eol=lf WiredTiger.lock eol=lf WiredTiger.turtle eol=lf -*.go diff=golang diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 888a5a7..df9e8ab 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,7 @@ jobs: # TODO: convert this to `services` - name: Start Unifi controller run: | - ./controller.sh + ./controller.sh start - name: Get dependencies run: | diff --git a/controller.sh b/controller.sh index dfae05b..40dd93f 100755 --- a/controller.sh +++ b/controller.sh @@ -1,20 +1,43 @@ #! /bin/bash +set -eou pipefail + # Local Administrator # Username: tfacctest # Password: tfacctest1234 # Email: tfacctest@example.com -docker run --rm --init -d \ - -p 8080:8080 \ - -p 8443:8443 \ - -p 3478:3478/udp \ - -p 10001:10001/udp \ - -e TZ='America/New_York' \ - -v $(pwd)/testdata/unifi:/unifi \ - --name unifi \ - jacobalberty/unifi:stable +if test $# -eq 0; then + echo "please specify either 'start' or 'test'" + exit 1 +fi -echo "Waiting for login page..." -timeout 300 bash -c 'while [[ "$(curl --insecure -s -o /dev/null -w "%{http_code}" https://localhost:8443/manage/account/login)" != "200" ]]; do sleep 5; done' -echo "Controller running." +case "$1" in + "start") + docker run --rm --init -d \ + -p 8080:8080 \ + -p 8443:8443 \ + -p 3478:3478/udp \ + -p 10001:10001/udp \ + -e TZ='America/New_York' \ + -v $(pwd)/testdata/unifi:/unifi \ + --name unifi \ + jacobalberty/unifi:stable + + echo "Waiting for login page..." + timeout 300 bash -c 'while [[ "$(curl --insecure -s -o /dev/null -w "%{http_code}" https://localhost:8443/manage/account/login)" != "200" ]]; do sleep 5; done' + echo "Controller running." + ;; + "test") + TF_ACC=1 \ + UNIFI_USERNAME=tfacctest \ + UNIFI_PASSWORD=tfacctest1234 \ + UNIFI_API="https://localhost:8443/api/" \ + UNIFI_ACC_WLAN_CONCURRENCY="4" \ + go test -v -cover ./internal/provider + ;; + *) + echo "unrecognized command" + exit 1 + ;; +esac \ No newline at end of file