Fix nbtb, add tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user