mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 07:33:21 -05:00
commit
c1346e8a65
35
.travis.yml
35
.travis.yml
@ -2,6 +2,7 @@ language: go
|
|||||||
|
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
|
- osx
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.9.x
|
- 1.9.x
|
||||||
@ -13,20 +14,44 @@ services:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
- MONEYGO_TEST_DB=sqlite
|
- MONEYGO_TEST_DB=sqlite
|
||||||
- MONEYGO_TEST_DB=mysql MONEYGO_TEST_DSN="root@tcp(127.0.0.1)/moneygo_test?parseTime=true"
|
- MONEYGO_TEST_DB=mysql
|
||||||
- MONEYGO_TEST_DB=postgres MONEYGO_TEST_DSN="postgres://postgres@localhost/moneygo_test"
|
- 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:
|
before_script:
|
||||||
- sh -c "if [ $MONEYGO_TEST_DB = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS moneygo_test;' -U postgres; fi"
|
- if [ $MONEYGO_TEST_DB = 'mysql' ]; then export MONEYGO_TEST_DSN="root@tcp(127.0.0.1)/moneygo_test?parseTime=true"; fi
|
||||||
- sh -c "if [ $MONEYGO_TEST_DB = 'postgres' ]; then psql -c 'CREATE DATABASE moneygo_test;' -U postgres; fi"
|
- if [ $MONEYGO_TEST_DB = 'postgres' ]; then export MONEYGO_TEST_DSN="postgres://postgres@localhost/moneygo_test?sslmode=disable"; 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 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:
|
script:
|
||||||
|
# Fetch/build coverage reporting tools
|
||||||
- go get golang.org/x/tools/cmd/cover
|
- go get golang.org/x/tools/cmd/cover
|
||||||
- go get github.com/mattn/goveralls
|
- go get github.com/mattn/goveralls
|
||||||
- go install github.com/mattn/goveralls
|
- go install github.com/mattn/goveralls
|
||||||
|
# Fetch MoneyGo itself
|
||||||
- go get -d github.com/aclindsa/moneygo
|
- 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
|
- 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 generate -v github.com/aclindsa/moneygo/internal/handlers
|
||||||
- go test -v -covermode=count -coverprofile=coverage.out 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
|
- $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
|
||||||
|
@ -3,12 +3,12 @@ package db
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/aclindsa/gorp"
|
||||||
"github.com/aclindsa/moneygo/internal/config"
|
"github.com/aclindsa/moneygo/internal/config"
|
||||||
"github.com/aclindsa/moneygo/internal/handlers"
|
"github.com/aclindsa/moneygo/internal/handlers"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"gopkg.in/gorp.v1"
|
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -25,7 +25,9 @@ func GetDbMap(db *sql.DB, dbtype config.DbType) (*gorp.DbMap, error) {
|
|||||||
Encoding: "UTF8",
|
Encoding: "UTF8",
|
||||||
}
|
}
|
||||||
} else if dbtype == config.Postgres {
|
} else if dbtype == config.Postgres {
|
||||||
dialect = gorp.PostgresDialect{}
|
dialect = gorp.PostgresDialect{
|
||||||
|
LowercaseFields: true,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("Don't know gorp dialect to go with '%s' DB type", dbtype.String())
|
return nil, fmt.Errorf("Don't know gorp dialect to go with '%s' DB type", dbtype.String())
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gopkg.in/gorp.v1"
|
"github.com/aclindsa/gorp"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
@ -65,8 +65,6 @@ func (t *TestData) initUser(user *User, userid int) error {
|
|||||||
|
|
||||||
t.clients = append(t.clients, client)
|
t.clients = append(t.clients, client)
|
||||||
|
|
||||||
// TODO initialize everything else owned by this user in the TestData struct
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"gopkg.in/gorp.v1"
|
"github.com/aclindsa/gorp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user