Skip to content

Commit

Permalink
test: fix flaky test
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Zeng <[email protected]>
  • Loading branch information
knight42 committed Jan 1, 2024
1 parent f84d6f5 commit 7937caa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ func NewTestEnv(t *testing.T) *TestEnv {
v := validator.New()
e.Validator = echoValidator(v.Struct)

// Connect to a temporary sqlite database.
db, err := gorm.Open(sqlite.Open(""), &gorm.Config{
dbFile, err := os.CreateTemp("", "yukid*.db")
require.NoError(t, err)
t.Cleanup(func() {
_ = os.Remove(dbFile.Name())
})
db, err := gorm.Open(sqlite.Open(dbFile.Name()), &gorm.Config{
QueryFields: true,
})
require.NoError(t, err)
Expand Down

0 comments on commit 7937caa

Please sign in to comment.