From edfe539ca39781a6bbc2e8b6ec9059de928bb79e Mon Sep 17 00:00:00 2001 From: Ralf Fischer Date: Tue, 4 Apr 2017 09:49:46 -0700 Subject: [PATCH] spin up arangodb in wercker --- .gitignore | 1 + config_test.go | 16 ++++++++++++++++ wercker.yml | 27 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 wercker.yml diff --git a/.gitignore b/.gitignore index 160100b..0a21202 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ _testmain.go *.test .* +.wercker \ No newline at end of file diff --git a/config_test.go b/config_test.go index c065bde..8f81b1e 100644 --- a/config_test.go +++ b/config_test.go @@ -1,5 +1,11 @@ package aranGO +import ( + "fmt" + "log" + "os" +) + // Configure to start testing var ( TestCollection = "TestCollection" @@ -13,6 +19,16 @@ var ( s *Session ) +func init() { + if wercker := os.Getenv("WERCKER"); wercker == "true" { + log.Printf("Found WERCKER env!") + arangoPort := os.Getenv("ARANGODB_PORT_8529_TCP_PORT") + arangoIP := os.Getenv("ARANGODB_PORT_8529_TCP_ADDR") + TestServer = fmt.Sprintf("http://%s:%s", arangoIP, arangoPort) + } + log.Printf("using TestServer at %s", TestServer) +} + // document to test type DocTest struct { Document // arango Document to save id, key, rev diff --git a/wercker.yml b/wercker.yml new file mode 100644 index 0000000..16fc6da --- /dev/null +++ b/wercker.yml @@ -0,0 +1,27 @@ +box: golang +services: + - id: arangodb + env: + ARANGO_NO_AUTH: 1 +build: + steps: + - install-packages: + packages: netcat + - setup-go-workspace: + package-dir: github.com/diegogub/aranGO + - script: + name: go get + code: | + go get -t + - script: + name: go build + code: | + go build ./... + - script: + name: Wait for Arangodb connection if it is slow + code: | + while ! nc -nvz $ARANGODB_PORT_8529_TCP_ADDR $ARANGODB_PORT_8529_TCP_PORT ; do echo "."; sleep 2; done + - script: + name: go test + code: | + go test ./...