Skip to content

Commit 041ac48

Browse files
committed
fix: add ORDER BY to asset links query and fix time-dependent test
- Add ORDER BY publication_id, position_index ASC to findBlockedForRecovery asset links query to preserve asset ordering (matching findByWorkspaceAndId pattern) - Replace hardcoded June 2026 dates in open-ended list test with runtime-relative dates to prevent flakiness as time progresses
1 parent 8e4aa2f commit 041ac48

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

server/smp/src/main/kotlin/com/profiletailors/smp/publishing/infrastructure/persistence/R2dbcPublishingRepositories.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ class R2dbcPublicationRepository(
316316
"""
317317
SELECT publication_id, asset_id FROM publication_asset_links
318318
WHERE publication_id IN (:ids)
319+
ORDER BY publication_id, position_index ASC
319320
""".trimIndent(),
320321
)
321322
.bind("ids", publicationIds)

server/smp/src/test/kotlin/com/profiletailors/smp/publishing/application/PublishingHandlersTest.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,10 +1215,16 @@ class PublishingHandlersTest {
12151215

12161216
@Test
12171217
fun `list publications open-ended uses broad date range`() = runTest {
1218+
// Use runtime-relative dates so the test never becomes flaky as time progresses.
1219+
// The handler derives its window from Clock.systemUTC(), so dates must fall
1220+
// within [now-90d, now+30d).
1221+
val now = java.time.Clock.systemUTC().instant()
1222+
val oneHourAgo = now.minus(java.time.Duration.ofHours(1))
1223+
val twoHoursAgo = now.minus(java.time.Duration.ofHours(2))
12181224
val publicationRepository = InMemoryPublicationRepository(
12191225
seedMany = listOf(
1220-
calendarPublication("pub-1", "account-1", "2026-06-15T10:00:00Z"),
1221-
calendarPublication("pub-2", "account-1", "2026-06-16T10:00:00Z"),
1226+
calendarPublication("pub-1", "account-1", oneHourAgo.toString()),
1227+
calendarPublication("pub-2", "account-1", twoHoursAgo.toString()),
12221228
),
12231229
)
12241230
val handler = ListPublicationsHandler(

0 commit comments

Comments
 (0)