Skip to content

Commit

Permalink
Change covermode to set and run tests in parallel.
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardKnop committed Jun 19, 2017
1 parent 24fb4da commit 629bada
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ test:

test-with-coverage:
# TODO: When Go 1.9 is released vendor folder should be ignored automatically
bash -c 'go list ./... | grep -v vendor | grep -v example | xargs -n1 go test -timeout=60s -race -coverprofile=coverage.txt -covermode=atomic'
bash -c 'go list ./... | grep -v vendor | grep -v example | xargs -n1 go test -timeout=30s -coverprofile=coverage.txt -covermode=set'
27 changes: 17 additions & 10 deletions load_postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ import (
_ "github.com/lib/pq"
)

var (
testPostgresDbUser = "go_fixtures"
testPostgresDbName = "go_fixtures_test"
)
const testPostgresDbUser = "go_fixtures"

func TestLoadWorksWithValidDataPostgres(t *testing.T) {
t.Parallel()

var (
db *sql.DB
err error
)

// Connect to a test Postgres db
db, err = rebuildDatabasePostgres(testPostgresDbUser, testPostgresDbName)
db, err = rebuildDatabasePostgres(testPostgresDbUser, "go_fixtures_test_load")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -250,13 +249,15 @@ func TestLoadWorksWithValidDataPostgres(t *testing.T) {
}

func TestLoadFileWorksWithValidFilePostgres(t *testing.T) {
t.Parallel()

var (
db *sql.DB
err error
)

// Connect to a test Postgres db
db, err = rebuildDatabasePostgres(testPostgresDbUser, testPostgresDbName)
db, err = rebuildDatabasePostgres(testPostgresDbUser, "go_fixtures_test_load_file")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -351,14 +352,16 @@ func TestLoadFileWorksWithValidFilePostgres(t *testing.T) {
assert.Equal(t, 0, count)
}

func TestLoadFileFailssWithMissingFilePostgres(t *testing.T) {
func TestLoadFileFailsWithMissingFilePostgres(t *testing.T) {
t.Parallel()

var (
db *sql.DB
err error
)

// Connect to a test Postgres db
db, err = rebuildDatabasePostgres(testPostgresDbUser, testPostgresDbName)
db, err = rebuildDatabasePostgres(testPostgresDbUser, "go_fixtures_test_load_file_missing_file")
if err != nil {
log.Fatal(err)
}
Expand All @@ -378,13 +381,15 @@ func TestLoadFileFailssWithMissingFilePostgres(t *testing.T) {
}

func TestLoadFilesWorksWithValidFilesPostgres(t *testing.T) {
t.Parallel()

var (
db *sql.DB
err error
)

// Connect to a test Postgres db
db, err = rebuildDatabasePostgres(testPostgresDbUser, testPostgresDbName)
db, err = rebuildDatabasePostgres(testPostgresDbUser, "go_fixtures_test_load_files")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -440,13 +445,15 @@ func TestLoadFilesWorksWithValidFilesPostgres(t *testing.T) {
}

func TestLoadFilesFailsWithABadFilePostgres(t *testing.T) {
t.Parallel()

var (
db *sql.DB
err error
)

// Connect to a test Postgres db
db, err = rebuildDatabasePostgres(testPostgresDbUser, testPostgresDbName)
db, err = rebuildDatabasePostgres(testPostgresDbUser, "go_fixtures_test_load_files_bad_file")
if err != nil {
log.Fatal(err)
}
Expand Down
24 changes: 21 additions & 3 deletions load_sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import (
_ "github.com/mattn/go-sqlite3"
)

var testSQLiteDb = "/tmp/fixtures_testdb.sqlite"

func TestLoadWorksWithValidDataSQLite(t *testing.T) {
t.Parallel()

var testSQLiteDb = "/tmp/fixtures_testdb_load.sqlite"

// Delete the test database
os.Remove(testSQLiteDb)

Expand Down Expand Up @@ -249,6 +251,10 @@ func TestLoadWorksWithValidDataSQLite(t *testing.T) {
}

func TestLoadFileWorksWithValidFileSQLite(t *testing.T) {
t.Parallel()

var testSQLiteDb = "/tmp/fixtures_testdb_load_file.sqlite"

// Delete the test database
os.Remove(testSQLiteDb)

Expand Down Expand Up @@ -353,7 +359,11 @@ func TestLoadFileWorksWithValidFileSQLite(t *testing.T) {
assert.Equal(t, 0, count)
}

func TestLoadFileFailssWithMissingFileSQLite(t *testing.T) {
func TestLoadFileFailsWithMissingFileSQLite(t *testing.T) {
t.Parallel()

var testSQLiteDb = "/tmp/fixtures_testdb_load_file_missing_file.sqlite"

// Delete the test database
os.Remove(testSQLiteDb)

Expand Down Expand Up @@ -383,6 +393,10 @@ func TestLoadFileFailssWithMissingFileSQLite(t *testing.T) {
}

func TestLoadFilesWorksWithValidFilesSQLite(t *testing.T) {
t.Parallel()

var testSQLiteDb = "/tmp/fixtures_testdb_load_files.sqlite"

// Delete the test database
os.Remove(testSQLiteDb)

Expand Down Expand Up @@ -448,6 +462,10 @@ func TestLoadFilesWorksWithValidFilesSQLite(t *testing.T) {
}

func TestLoadFilesFailsWithABadFileSQLite(t *testing.T) {
t.Parallel()

var testSQLiteDb = "/tmp/fixtures_testdb_load_files_bad_file.sqlite"

// Delete the test database
os.Remove(testSQLiteDb)

Expand Down
2 changes: 2 additions & 0 deletions row_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestRow(t *testing.T) {
t.Parallel()

// Create a test Row instance
row := &fixtures.Row{
Table: "some_table",
Expand Down

0 comments on commit 629bada

Please sign in to comment.