test: update cleanup test for new RESERVATION:user: description format
Test was using RESERVATION:{user_id}:timestamp which no longer matches
the dual-TTL cleanup patterns. Updated to RESERVATION:user:{user_id}:{timestamp}.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -612,13 +612,13 @@ func TestCleanupOldReservations(t *testing.T) {
|
||||
oldTime := time.Now().Add(-2 * time.Hour).In(ukLocation)
|
||||
_, err = db.DB.Exec(ctx, `
|
||||
INSERT INTO time_blockers (start_time, duration_minutes, description, created_by)
|
||||
VALUES ($1, 60, $2, $3)`, oldTime, fmt.Sprintf("RESERVATION:%s:timestamp-old", oldUserID), oldUserID)
|
||||
VALUES ($1, 60, $2, $3)`, oldTime, fmt.Sprintf("RESERVATION:user:%s:%d", oldUserID, time.Now().UnixNano()), oldUserID)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create old reservation: %v", err)
|
||||
}
|
||||
|
||||
// Set old created_at to make it eligible for cleanup (> 1 hour old)
|
||||
_, err = db.DB.Exec(ctx, `UPDATE time_blockers SET created_at = $1 WHERE description LIKE 'RESERVATION:%' AND start_time = $2`, time.Now().Add(-2*time.Hour), oldTime)
|
||||
_, err = db.DB.Exec(ctx, `UPDATE time_blockers SET created_at = $1 WHERE description LIKE 'RESERVATION:user:%' AND start_time = $2`, time.Now().Add(-2*time.Hour), oldTime)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to update old reservation created_at: %v", err)
|
||||
}
|
||||
@@ -627,13 +627,13 @@ func TestCleanupOldReservations(t *testing.T) {
|
||||
recentTime := time.Now().Add(-30 * time.Minute).In(ukLocation)
|
||||
_, err = db.DB.Exec(ctx, `
|
||||
INSERT INTO time_blockers (start_time, duration_minutes, description, created_by)
|
||||
VALUES ($1, 60, $2, $3)`, recentTime, fmt.Sprintf("RESERVATION:%s:timestamp-recent", recentUserID), recentUserID)
|
||||
VALUES ($1, 60, $2, $3)`, recentTime, fmt.Sprintf("RESERVATION:user:%s:%d", recentUserID, time.Now().UnixNano()), recentUserID)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create recent reservation: %v", err)
|
||||
}
|
||||
|
||||
// Set recent created_at to recent (< 1 hour old) so it's NOT deleted
|
||||
_, err = db.DB.Exec(ctx, `UPDATE time_blockers SET created_at = $1 WHERE description LIKE 'RESERVATION:%' AND start_time = $2`, time.Now().Add(-30*time.Minute), recentTime)
|
||||
_, err = db.DB.Exec(ctx, `UPDATE time_blockers SET created_at = $1 WHERE description LIKE 'RESERVATION:user:%' AND start_time = $2`, time.Now().Add(-30*time.Minute), recentTime)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to update recent reservation created_at: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user