Last active
October 25, 2019 23:44
-
-
Save efueyo/e6b20a5c36dd6b94807939b69e7d4de4 to your computer and use it in GitHub Desktop.
TestFixtures.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fixtures *testfixtures.Context | |
func TestMain(m *testing.M) { // errors skipped for brevity here | |
db, _ := sql.Open("postgres", "dbname=myapp_test") | |
fixtures, _ = testfixtures.NewFolder(db, &testfixtures.PostgreSQL{}, "testdata/fixtures") | |
os.Exit(m.Run()) | |
} | |
// now remember to call fixtures.Load() at the beginning of every tests and check for errors | |
// in Ginkgo you can use BeforeEach like: | |
var _ = Describe("My Test", func() { | |
BeforeEach(func() { | |
err := fixtures.Load() | |
Expect(err).ToNot(HaveOccurred()) | |
}) | |
... | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment