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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wwk8tDEaEvsNoGbtrjZavz
This commit is contained in:
Vitor Pamplona
2026-09-09 09:39:45 -04:00
co-authored by Claude Opus 5
parent 497859dc76
commit 96133560ff
2 changed files with 8 additions and 8 deletions
@@ -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)
@@ -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"),