Skip to content

Commit

Permalink
simplify test fixtures now that all tests use the email-based token
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Dec 9, 2023
1 parent e9495ff commit 65e3326
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ type TestSuite struct {
tx *gorm.DB
}

type Fixtures struct {
Tenants []db.Tenant
Users []db.User
}

// SetupTest runs before every test function
func (ts *TestSuite) SetupTest() {
ts.Assertions = require.New(ts.T())
Expand Down Expand Up @@ -68,21 +73,10 @@ func (ts *TestSuite) createUserFixture() Fixtures {
createdUser, err := db.CreateUser(ts.ctx, fakeUserCreate)
ts.NoError(err)

newToken, err := db.CreateToken(ts.ctx, app.TokenCreateInput{
UserID: createdUser.ID,
AuthID: createdUser.ID,
ExpiresAt: time.Now().Add(time.Hour * 24),
})
ts.NoError(err)
if err != nil {
return Fixtures{}
}

ts.createTokenFixture(createdUser.Email, createdUser.ID)

return Fixtures{
Users: []db.User{createdUser},
Tokens: []db.Token{newToken},
Users: []db.User{createdUser},
}
}

Expand All @@ -98,12 +92,6 @@ func (ts *TestSuite) createTenantFixture() Fixtures {
}
}

type Fixtures struct {
Tenants []db.Tenant
Tokens []db.Token
Users []db.User
}

func deleteAll(c echo.Context, i any) {
result := db.Tx(c).Where("TRUE").Delete(i)
if result.Error != nil {
Expand Down

0 comments on commit 65e3326

Please sign in to comment.