Files
hatchet/internal/testutils/with_database.go
Luca Steeb c8f87599c7 chore: ignore or fix linter errors (#116)
* chore: ignore or fix linter errors

* chore: wrap up lint errors

* chore: sqlc generation

---------

Co-authored-by: Alexander Belanger <belanger@sas.upenn.edu>
2024-01-21 22:01:20 -05:00

28 lines
539 B
Go

package testutils
import (
"testing"
"github.com/hatchet-dev/hatchet/internal/config/database"
"github.com/hatchet-dev/hatchet/internal/config/loader"
)
func RunTestWithDatabase(t *testing.T, test func(config *database.Config) error) {
t.Helper()
Prepare(t)
confLoader := &loader.ConfigLoader{}
conf, err := confLoader.LoadDatabaseConfig()
if err != nil {
t.Fatalf("failed to load database config: %v\n", err)
}
defer conf.Disconnect() // nolint: errcheck
err = test(conf)
if err != nil {
t.Fatalf("%v\n", err)
}
}