From 42d95156a08596c65b44feb6817d38b07386531f Mon Sep 17 00:00:00 2001 From: hirasawayuki Date: Mon, 18 Sep 2023 15:07:12 +0900 Subject: [PATCH] enhance dbfixture.New to accept IDB interface --- dbfixture/encoder.go | 4 ++-- dbfixture/fixture.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbfixture/encoder.go b/dbfixture/encoder.go index 4e615e7df..3e35dc8dc 100644 --- a/dbfixture/encoder.go +++ b/dbfixture/encoder.go @@ -15,11 +15,11 @@ type fixtureRows struct { } type Encoder struct { - db *bun.DB + db bun.IDB enc *yaml.Encoder } -func NewEncoder(db *bun.DB, w io.Writer) *Encoder { +func NewEncoder(db bun.IDB, w io.Writer) *Encoder { return &Encoder{ db: db, enc: yaml.NewEncoder(w), diff --git a/dbfixture/fixture.go b/dbfixture/fixture.go index 0d84d5d18..770d86151 100644 --- a/dbfixture/fixture.go +++ b/dbfixture/fixture.go @@ -69,7 +69,7 @@ func WithBeforeInsert(fn BeforeInsertFunc) FixtureOption { } type Fixture struct { - db *bun.DB + db bun.IDB recreateTables bool truncateTables bool @@ -81,7 +81,7 @@ type Fixture struct { modelRows map[string]map[string]interface{} } -func New(db *bun.DB, opts ...FixtureOption) *Fixture { +func New(db bun.IDB, opts ...FixtureOption) *Fixture { f := &Fixture{ db: db,