Skip to content

Commit

Permalink
feat: factory: remove debug field (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn authored Dec 22, 2024
1 parent d7c13ee commit acc5010
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 20 deletions.
2 changes: 0 additions & 2 deletions server/testing/factory/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ func (f *Factory) NewAuth(opts ...AuthOpt) *orm.Auth {
opt(m)
}

boil.DebugMode = f.debug
if err = m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert user: %w", err))
}
boil.DebugMode = false

return m
}
Expand Down
2 changes: 0 additions & 2 deletions server/testing/factory/exercise.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ func (f *Factory) NewExercise(opts ...ExerciseOpt) *orm.Exercise {
m.UserID = f.NewUser().ID
}

boil.DebugMode = f.debug
if err := m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert exercise: %w", err))
}
boil.DebugMode = false

user, err := m.User().One(context.Background(), f.db)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions server/testing/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import (
type Factory struct {
db *sql.DB
faker *gofakeit.Faker
debug bool
}

func NewFactory(db *sql.DB) *Factory {
return &Factory{
db: db,
faker: gofakeit.New(0),
debug: false,
}
}

Expand Down
2 changes: 0 additions & 2 deletions server/testing/factory/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ func (f *Factory) NewNotification(opts ...NotificationOpt) *orm.Notification {
m.Payload = []byte("{}")
}

boil.DebugMode = f.debug
if err := m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert notification: %w", err))
}
boil.DebugMode = false

user, err := m.User().One(context.Background(), f.db)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions server/testing/factory/routine.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ func (f *Factory) NewRoutine(opts ...RoutineOpt) *orm.Routine {
m.UserID = f.NewUser().ID
}

boil.DebugMode = f.debug
if err := m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert routine: %w", err))
}
boil.DebugMode = false

user, err := m.User().One(context.Background(), f.db)
if err != nil {
Expand Down Expand Up @@ -89,9 +87,7 @@ func RoutineExerciseOrder(exerciseIDs []string) RoutineOpt {
}

func (f *Factory) AddRoutineExercise(routine *orm.Routine, exercises ...*orm.Exercise) {
boil.DebugMode = f.debug
if err := routine.AddExercises(context.Background(), f.db, false, exercises...); err != nil {
panic(fmt.Errorf("failed to add exercises to routine: %w", err))
}
boil.DebugMode = false
}
2 changes: 0 additions & 2 deletions server/testing/factory/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ func (f *Factory) NewSet(opts ...SetOpt) *orm.Set {
m.ExerciseID = f.NewExercise().ID
}

boil.DebugMode = f.debug
if err := m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert set: %w", err))
}
boil.DebugMode = false

workout, err := m.Workout().One(context.Background(), f.db)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions server/testing/factory/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ func (f *Factory) NewUser(opts ...UserOpt) *orm.User {
m.AuthID = f.NewAuth().ID
}

boil.DebugMode = f.debug
if err := m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert user: %w", err))
}
boil.DebugMode = false

auth, err := m.Auth().One(context.Background(), f.db)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions server/testing/factory/workout.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ func (f *Factory) NewWorkout(opts ...WorkoutOpt) *orm.Workout {
m.UserID = f.NewUser().ID
}

boil.DebugMode = f.debug
if err := m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert workout: %w", err))
}
boil.DebugMode = false

user, err := m.User().One(context.Background(), f.db)
if err != nil {
Expand Down Expand Up @@ -115,11 +113,9 @@ func (f *Factory) NewWorkoutComment(opts ...WorkoutCommentOpt) *orm.WorkoutComme
m.WorkoutID = f.NewWorkout().ID
}

boil.DebugMode = f.debug
if err := m.Insert(context.Background(), f.db, boil.Infer()); err != nil {
panic(fmt.Errorf("failed to insert workout comment: %w", err))
}
boil.DebugMode = false

user, err := m.User().One(context.Background(), f.db)
if err != nil {
Expand Down

0 comments on commit acc5010

Please sign in to comment.