Fix nbtb, add tests

This commit is contained in:
2026-03-04 20:11:51 +00:00
parent 29b9776a93
commit 7c3f922725
7 changed files with 522 additions and 12 deletions
+26
View File
@@ -6,6 +6,7 @@ package fixtures
import (
"context"
"fmt"
"time"
"github.com/jackc/pgx/v5/pgxpool"
"golang.org/x/crypto/bcrypt"
@@ -202,3 +203,28 @@ func SafeDeleteService(db *pgxpool.Pool, serviceID string) error {
func SafeDeleteBooking(db *pgxpool.Pool, bookingID string) error {
return DeleteBooking(db, bookingID)
}
// CreateTestTimeBlocker creates a time blocker for testing
// Returns the blocker ID
func CreateTestTimeBlocker(pool *pgxpool.Pool, startTime time.Time, durationMinutes int, description string) (string, error) {
ctx := context.Background()
var blockerID string
err := pool.QueryRow(ctx, `
INSERT INTO time_blockers (start_time, duration_minutes, description)
VALUES ($1, $2, $3)
RETURNING id
`, startTime, durationMinutes, description).Scan(&blockerID)
if err != nil {
return "", fmt.Errorf("failed to create time blocker: %w", err)
}
return blockerID, nil
}
// DeleteTimeBlocker removes a time blocker from the database
func DeleteTimeBlocker(pool *pgxpool.Pool, blockerID string) error {
ctx := context.Background()
_, err := pool.Exec(ctx, "DELETE FROM time_blockers WHERE id = $1", blockerID)
return err
}