added unit tests for postgres and mysql

This commit is contained in:
Brad Rydzewski 2014-09-30 23:30:42 -07:00
parent 892703b3f2
commit 6b721f5b98
4 changed files with 15 additions and 3 deletions

View file

@ -8,7 +8,12 @@ script:
- sudo apt-get -y install zip libsqlite3-dev sqlite3 1> /dev/null 2> /dev/null - sudo apt-get -y install zip libsqlite3-dev sqlite3 1> /dev/null 2> /dev/null
- make deps - make deps
- make test - make test
- make test_postgres
- make test_mysql
- make dpkg - make dpkg
services:
- postgres
- mysql
notify: notify:
email: email:
recipients: recipients:

View file

@ -12,6 +12,13 @@ test:
go vet ./... go vet ./...
go test -cover -short ./... go test -cover -short ./...
test_mysql:
mysql -P 3306 --protocol=tcp -u root -e 'create database test;'
TEST_DRIVER="mysql" TEST_DATASOURCE="root@tcp(127.0.0.1:3306)/test" go test -short github.com/drone/drone/server/datastore/database
test_postgres:
TEST_DRIVER="postgres" TEST_DATASOURCE="host=127.0.0.1 user=postgres dbname=postgres sslmode=disable" go test -short github.com/drone/drone/server/datastore/database
build: build:
go build -o debian/drone/usr/local/bin/drone -ldflags "-X main.revision $(SHA)" github.com/drone/drone/cli go build -o debian/drone/usr/local/bin/drone -ldflags "-X main.revision $(SHA)" github.com/drone/drone/cli
go build -o debian/drone/usr/local/bin/droned -ldflags "-X main.revision $(SHA)" github.com/drone/drone/server go build -o debian/drone/usr/local/bin/droned -ldflags "-X main.revision $(SHA)" github.com/drone/drone/server

View file

@ -111,7 +111,7 @@ CREATE TABLE IF NOT EXISTS commits (
var blobTable = ` var blobTable = `
CREATE TABLE IF NOT EXISTS blobs ( CREATE TABLE IF NOT EXISTS blobs (
blob_id INTEGER PRIMARY KEY AUTOINCREMENT blob_id INTEGER PRIMARY KEY AUTOINCREMENT
,blob_path VARCHAR(1024) ,blob_path VARCHAR(255)
,blob_data BLOB ,blob_data BLOB
,UNIQUE(blob_path) ,UNIQUE(blob_path)
); );

View file

@ -74,10 +74,10 @@ func main() {
flag.StringVar(&conf, "config", "", "") flag.StringVar(&conf, "config", "", "")
flag.StringVar(&prefix, "prefix", "DRONE_", "") flag.StringVar(&prefix, "prefix", "DRONE_", "")
flag.StringVar(&driver, "driver", "sqlite3", "")
flag.StringVar(&datasource, "datasource", "drone.sqlite", "")
flag.Parse() flag.Parse()
config.StringVar(&datasource, "database-path", "drone.sqlite")
config.StringVar(&driver, "database-driver", "sqlite3")
config.Var(&nodes, "worker-nodes") config.Var(&nodes, "worker-nodes")
config.BoolVar(&open, "registration-open", false) config.BoolVar(&open, "registration-open", false)
config.SetPrefix(prefix) config.SetPrefix(prefix)