From 269ca2e7e58cae30d06f2beb02d7769a6f34064b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Lindstr=C3=B6m?= Date: Tue, 8 Sep 2015 13:48:20 +0000 Subject: [PATCH] Update tests to use TravisCI This will remove the current .drone.yml which isn't used anymore, update the Makefile target and move tests to using `t.Skip` instead of `t.Fatal` if no database exists during tests. This is so it's possible to develop new tests that may not require a database. --- .drone.yml | 10 ---------- .travis.yml | 18 ++++++++++++++++++ Makefile | 4 ++-- cleanup_test.go | 2 +- pgstore_test.go | 4 ++-- 5 files changed, 23 insertions(+), 15 deletions(-) delete mode 100644 .drone.yml create mode 100644 .travis.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index e1c21b9..0000000 --- a/.drone.yml +++ /dev/null @@ -1,10 +0,0 @@ -image: go1.2 -env: - - GOPATH=/var/cache/drone -services: - - postgres -script: - - export PGSTORE_TEST_CONN="postgres://postgres@127.0.0.1/test?sslmode=disable" - - psql -c 'create database test;' -U postgres -h 127.0.0.1 - - make - - make test diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..64ab288 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: go + +go: + - 1.2 + - tip + +script: make test + +env: + - PGSTORE_TEST_CONN="postgres://postgres@127.0.0.1/test?sslmode=disable" + +before_script: + - psql -c 'create database test;' -U postgres + +addons: + postgresql: "9.3" + +sudo: false diff --git a/Makefile b/Makefile index 9a459c8..735beee 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ build: get-deps: @go get -d -v ./... -test: - @go test ./... +test: get-deps + @go test -v ./... format: @go fmt ./... diff --git a/cleanup_test.go b/cleanup_test.go index 6ef53ae..1b18679 100644 --- a/cleanup_test.go +++ b/cleanup_test.go @@ -10,7 +10,7 @@ import ( func TestCleanup(t *testing.T) { ss := NewPGStore(os.Getenv("PGSTORE_TEST_CONN"), []byte(secret)) if ss == nil { - t.Fatal("This test requires a real database") + t.Skip("This test requires a real database") } defer ss.Close() diff --git a/pgstore_test.go b/pgstore_test.go index 2cafe06..f76981d 100644 --- a/pgstore_test.go +++ b/pgstore_test.go @@ -30,7 +30,7 @@ func TestPGStore(t *testing.T) { ss := NewPGStore(os.Getenv("PGSTORE_TEST_CONN"), []byte(secret)) if ss == nil { - t.Fatal("This test requires a real database") + t.Skip("This test requires a real database") } defer ss.Close() @@ -124,7 +124,7 @@ func TestSessionOptionsAreUniquePerSession(t *testing.T) { ss := NewPGStore(os.Getenv("PGSTORE_TEST_CONN"), []byte(secret)) if ss == nil { - t.Fatal("This test requires a real database") + t.Skip("This test requires a real database") } defer ss.Close()