1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-10-30 07:40:05 -04:00

Merge pull request #27 from aclindsa/travis_fixups

Travis fixups
This commit is contained in:
Aaron Lindsay 2017-11-17 21:44:43 -05:00 committed by GitHub
commit c1346e8a65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 11 deletions

View File

@ -2,6 +2,7 @@ language: go
os:
- linux
- osx
go:
- 1.9.x
@ -13,20 +14,44 @@ services:
env:
- MONEYGO_TEST_DB=sqlite
- MONEYGO_TEST_DB=mysql MONEYGO_TEST_DSN="root@tcp(127.0.0.1)/moneygo_test?parseTime=true"
- MONEYGO_TEST_DB=postgres MONEYGO_TEST_DSN="postgres://postgres@localhost/moneygo_test"
- MONEYGO_TEST_DB=mysql
- MONEYGO_TEST_DB=postgres
# OSX builds take too long, so don't wait for all of them
matrix:
fast_finish: true
allow_failures:
- os: osx
go: master
# Install MySQL or Postgres if on OSX
before_install:
- if [ $TRAVIS_OS_NAME = 'osx' ] && [ $MONEYGO_TEST_DB = 'mysql' ]; then brew update > /dev/null && brew install mariadb && mysql.server start; fi
- if [ $TRAVIS_OS_NAME = 'osx' ] && [ $MONEYGO_TEST_DB = 'postgres' ]; then brew update > /dev/null; fi
- if [ $TRAVIS_OS_NAME = 'osx' ] && [ $MONEYGO_TEST_DB = 'postgres' ]; then rm -rf /usr/local/var/postgres; fi
- if [ $TRAVIS_OS_NAME = 'osx' ] && [ $MONEYGO_TEST_DB = 'postgres' ]; then initdb /usr/local/var/postgres; fi
- if [ $TRAVIS_OS_NAME = 'osx' ] && [ $MONEYGO_TEST_DB = 'postgres' ]; then pg_ctl -D /usr/local/var/postgres start; fi
- if [ $TRAVIS_OS_NAME = 'osx' ] && [ $MONEYGO_TEST_DB = 'postgres' ]; then createuser -s postgres; fi
# Initialize databases, if testing MySQL or Postgres
before_script:
- sh -c "if [ $MONEYGO_TEST_DB = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS moneygo_test;' -U postgres; fi"
- sh -c "if [ $MONEYGO_TEST_DB = 'postgres' ]; then psql -c 'CREATE DATABASE moneygo_test;' -U postgres; fi"
- sh -c "if [ $MONEYGO_TEST_DB = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS moneygo_test;'; fi"
- if [ $MONEYGO_TEST_DB = 'mysql' ]; then export MONEYGO_TEST_DSN="root@tcp(127.0.0.1)/moneygo_test?parseTime=true"; fi
- if [ $MONEYGO_TEST_DB = 'postgres' ]; then export MONEYGO_TEST_DSN="postgres://postgres@localhost/moneygo_test?sslmode=disable"; fi
- if [ $MONEYGO_TEST_DB = 'mysql' ]; then mysql -u root -e 'CREATE DATABASE IF NOT EXISTS moneygo_test;'; fi
- if [ $MONEYGO_TEST_DB = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS moneygo_test;' -U postgres; fi
- if [ $MONEYGO_TEST_DB = 'postgres' ]; then psql -c 'CREATE DATABASE moneygo_test;' -U postgres; fi
script:
# Fetch/build coverage reporting tools
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go install github.com/mattn/goveralls
# Fetch MoneyGo itself
- go get -d github.com/aclindsa/moneygo
# Don't allow the test to query for a full list of all CUSIPs
- touch $GOPATH/src/github.com/aclindsa/moneygo/internal/handlers/cusip_list.csv
# Build and test MoneyGo
- go generate -v github.com/aclindsa/moneygo/internal/handlers
- go test -v -covermode=count -coverprofile=coverage.out github.com/aclindsa/moneygo/internal/handlers
# Finally, report the test coverage
- $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN

View File

@ -3,12 +3,12 @@ package db
import (
"database/sql"
"fmt"
"github.com/aclindsa/gorp"
"github.com/aclindsa/moneygo/internal/config"
"github.com/aclindsa/moneygo/internal/handlers"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
"gopkg.in/gorp.v1"
"log"
"strings"
)
@ -25,7 +25,9 @@ func GetDbMap(db *sql.DB, dbtype config.DbType) (*gorp.DbMap, error) {
Encoding: "UTF8",
}
} else if dbtype == config.Postgres {
dialect = gorp.PostgresDialect{}
dialect = gorp.PostgresDialect{
LowercaseFields: true,
}
} else {
return nil, fmt.Errorf("Don't know gorp dialect to go with '%s' DB type", dbtype.String())
}

View File

@ -1,7 +1,7 @@
package handlers
import (
"gopkg.in/gorp.v1"
"github.com/aclindsa/gorp"
"log"
"net/http"
"path"

View File

@ -65,8 +65,6 @@ func (t *TestData) initUser(user *User, userid int) error {
t.clients = append(t.clients, client)
// TODO initialize everything else owned by this user in the TestData struct
return nil
}

View File

@ -2,7 +2,7 @@ package handlers
import (
"database/sql"
"gopkg.in/gorp.v1"
"github.com/aclindsa/gorp"
"strings"
)