From 96133560ffb2f6fa26fe5df54e43d746b57a739c Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 9 Sep 2026 09:38:54 -0400 Subject: [PATCH] test(search): stop the date tests asserting UTC when the parser means local Six tests failed on any machine outside UTC, by exactly that machine's offset: QueryParserTest sinceDate, sinceDateYearOnly, combinedQuery QuerySerializerTest sinceDate, untilDate, combinedQuery They hardcoded 1735689600L -- 2025-01-01 midnight *UTC* -- but the parser now returns the reader's own midnight, and the serializer formats through `DateUtils.localDay`. In America/New_York the parser answered 1735707600 and the serializer rendered "2024-12-31", both correct. The production code is right; the assertions were left behind when the bound became local. The same file already had it right further down, where the newer cases assert `LocalClock.startOfDay(SearchDate(...))` under a comment explaining that a bound is the reader's midnight and not UTC's. These six now say the same thing, so they state the intended behaviour rather than the behaviour of a UTC build machine. `timestampToDate2025` keeps its UTC literal deliberately: `timestampToDate` is plain epoch arithmetic in `DateUtils`, not the local formatter `serialize` uses. Changing it would have broken a passing test -- the two paths in `QuerySerializer` genuinely differ. Verified green in America/New_York, UTC, Pacific/Auckland and Asia/Kolkata -- 37 + 19 tests, zero failures in each. Full quartz, commons and amethyst suites pass locally, which they did not before this. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01Wwk8tDEaEvsNoGbtrjZavz --- .../amethyst/commons/search/QueryParserTest.kt | 8 +++----- .../amethyst/commons/search/QuerySerializerTest.kt | 8 +++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QueryParserTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QueryParserTest.kt index 1c83855465..c34a12f489 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QueryParserTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QueryParserTest.kt @@ -101,15 +101,13 @@ class QueryParserTest { @Test fun sinceDate() { val q = QueryParser.parse("since:2025-01-01") - // 2025-01-01 00:00:00 UTC - assertEquals(1735689600L, q.since) + assertEquals(LocalClock.startOfDay(SearchDate(2025, 1, 1)), q.since) } @Test fun sinceDateYearOnly() { val q = QueryParser.parse("since:2025") - // 2025-01-01 00:00:00 UTC - assertEquals(1735689600L, q.since) + assertEquals(LocalClock.startOfDay(SearchDate(2025, 1, 1)), q.since) } @Test @@ -214,7 +212,7 @@ class QueryParserTest { fun combinedQuery() { val q = QueryParser.parse("kind:note since:2025-01-01 #bitcoin -spam lightning") assertEquals(listOf(1), q.kinds.toList()) - assertEquals(1735689600L, q.since) + assertEquals(LocalClock.startOfDay(SearchDate(2025, 1, 1)), q.since) assertEquals(listOf("bitcoin"), q.hashtags.toList()) assertEquals(listOf("spam"), q.excludeTerms.toList()) assertEquals("lightning", q.text) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QuerySerializerTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QuerySerializerTest.kt index 0534e50138..94b9754bdc 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QuerySerializerTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/QuerySerializerTest.kt @@ -20,6 +20,8 @@ */ package com.vitorpamplona.amethyst.commons.search +import com.vitorpamplona.amethyst.commons.search.calendar.LocalClock +import com.vitorpamplona.amethyst.commons.search.calendar.SearchDate import kotlinx.collections.immutable.persistentListOf import kotlin.test.Test import kotlin.test.assertEquals @@ -63,13 +65,13 @@ class QuerySerializerTest { @Test fun sinceDate() { - val q = SearchQuery(since = 1735689600L) // 2025-01-01 + val q = SearchQuery(since = LocalClock.startOfDay(SearchDate(2025, 1, 1))) assertEquals("since:2025-01-01", QuerySerializer.serialize(q)) } @Test fun untilDate() { - val q = SearchQuery(until = 1735689600L) + val q = SearchQuery(until = LocalClock.startOfDay(SearchDate(2025, 1, 1))) assertEquals("until:2025-01-01", QuerySerializer.serialize(q)) } @@ -115,7 +117,7 @@ class QuerySerializerTest { SearchQuery( authorNames = persistentListOf("vitor"), kinds = persistentListOf(1), - since = 1735689600L, + since = LocalClock.startOfDay(SearchDate(2025, 1, 1)), hashtags = persistentListOf("bitcoin"), text = "lightning", excludeTerms = persistentListOf("spam"),