package adapter_test import ( "flag" "log" "os" "testing" "gitea.dwysokinski.me/twhelp/corev3/internal/adapter/adaptertest" "github.com/ory/dockertest/v3" ) var postgres *adaptertest.Postgres func TestMain(m *testing.M) { os.Exit(testMainWrapper(m)) } func testMainWrapper(m *testing.M) int { // https://github.com/golang/go/blob/7cfa7d69259590319524c3715df4a39b39924bc3/src/testing/testing.go#L224 flag.Parse() if testing.Short() { return m.Run() } pool, err := dockertest.NewPool("") if err != nil { log.Println("couldn't construct dockertest.Pool:", err) return 1 } postgres, err = adaptertest.NewPostgres(pool) if err != nil { log.Println("couldn't construct adaptertest.Postgres:", err) return 1 } defer func() { _ = postgres.Close() }() return m.Run() }