Cleanup: remove unused code

This commit is contained in:
Sybren A. Stüvel 2024-12-04 14:05:50 +01:00
parent 531a0184f7
commit 7be05afa11
3 changed files with 0 additions and 55 deletions

View File

@ -10,7 +10,3 @@ func nullTimeToUTC(t sql.NullTime) sql.NullTime {
Valid: t.Valid,
}
}
func ptr[T any](value T) *T {
return &value
}

View File

@ -297,17 +297,3 @@ func testFixtures(t *testing.T) (*SleepScheduler, TestMocks, context.Context) {
ss := New(mocks.clock, mocks.persist, mocks.broadcaster)
return ss, mocks, ctx
}
func createTestWorker(updaters ...func(*persistence.Worker)) persistence.Worker {
w := persistence.Worker{
ID: 47,
UUID: "4f2d3755-c365-429f-8017-44356427c069",
Name: "schedule test worker",
}
for _, updater := range updaters {
updater(&w)
}
return w
}

View File

@ -150,49 +150,12 @@ func (db *DB) queries() *sqlc.Queries {
return sqlc.New(&loggingWrapper)
}
type queriesTX struct {
queries *sqlc.Queries
commit func() error
rollback func() error
}
// queries returns the SQLC Queries struct, connected to this database.
//
// After calling this function, all queries should use this transaction until it
// is closed (either committed or rolled back). Otherwise SQLite will deadlock,
// as it will make any other query wait until this transaction is done.
func (db *DB) queriesWithTX() (*queriesTX, error) {
tx, err := db.sqlDB.Begin()
if err != nil {
return nil, fmt.Errorf("could not begin database transaction: %w", err)
}
loggingWrapper := LoggingDBConn{tx}
qtx := queriesTX{
queries: sqlc.New(&loggingWrapper),
commit: tx.Commit,
rollback: tx.Rollback,
}
return &qtx, nil
}
// now returns 'now' as reported by db.nowfunc.
// It always converts the timestamp to UTC.
func (db *DB) now() time.Time {
return db.nowfunc()
}
// nowNullable returns the result of `now()` wrapped in a sql.NullTime.
// It is nullable just for ease of use, it will never actually be null.
func (db *DB) nowNullable() sql.NullTime {
return sql.NullTime{
Time: db.now(),
Valid: true,
}
}
func (db *DB) pragmaForeignKeys(ctx context.Context, enabled bool) error {
var noun string
switch enabled {