Skip to content

Commit 1c44b56

Browse files
committed
test(time): drop redundant comments in timestamp tests
1 parent ea0baf9 commit 1c44b56

3 files changed

Lines changed: 3 additions & 41 deletions

File tree

browser/chromium/chromium_test.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,7 @@ func TestSetKeyRetrievers_SatisfiesInterface(t *testing.T) {
722722
} = (*Browser)(nil)
723723
}
724724

725-
// ---------------------------------------------------------------------------
726-
// timeEpoch
727-
// ---------------------------------------------------------------------------
728-
729-
// Anchor: 2024-01-15T10:30:00Z = Unix seconds 1705314600. Chromium stores
730-
// this as microseconds since 1601-01-01 UTC, so the stored value is
731-
// (1705314600 + 11644473600) * 1e6.
725+
// Anchor: 2024-01-15T10:30:00Z as Chromium microseconds since 1601 UTC.
732726
const anchorUnixSeconds = int64(1705314600)
733727

734728
var anchorChromiumMicros = (anchorUnixSeconds + 11644473600) * 1_000_000
@@ -741,41 +735,30 @@ func TestTimeEpoch_AnchorDate(t *testing.T) {
741735
}
742736

743737
func TestTimeEpoch_ZeroReturnsZeroTime(t *testing.T) {
744-
// Chromium uses 0 for session cookies (no persistent expiry).
745738
assert.True(t, timeEpoch(0).IsZero())
746739
}
747740

748741
func TestTimeEpoch_NegativeReturnsZeroTime(t *testing.T) {
749-
// -1 is the legacy "never expires" sentinel on older profiles.
750742
assert.True(t, timeEpoch(-1).IsZero())
751743
}
752744

753745
func TestTimeEpoch_AlwaysUTC(t *testing.T) {
754-
// Location must be UTC regardless of the test runner's TZ. Set a
755-
// non-UTC local zone via t.Setenv so the assertion catches any
756-
// accidental time.Local usage.
757746
t.Setenv("TZ", "Asia/Shanghai")
758747
got := timeEpoch(anchorChromiumMicros)
759748
assert.Equal(t, time.UTC, got.Location())
760749
}
761750

762751
func TestTimeEpoch_MicrosecondPrecisionPreserved(t *testing.T) {
763-
// Add 123456 μs to the anchor and confirm the nanosecond component
764-
// survives the conversion (no silent truncation to seconds).
765752
got := timeEpoch(anchorChromiumMicros + 123456)
766753
assert.Equal(t, 123456*int64(time.Microsecond), int64(got.Nanosecond()))
767754
}
768755

769756
func TestTimeEpoch_UnixEpochBoundary(t *testing.T) {
770-
// Exactly the offset constant → 1970-01-01T00:00:00 UTC.
771757
got := timeEpoch(chromiumEpochOffsetMicros)
772758
assert.Equal(t, time.Unix(0, 0).UTC(), got)
773759
}
774760

775761
func TestTimeEpoch_OutOfJSONRangeReturnsZero(t *testing.T) {
776-
// Some sites write nonsense "never expires" sentinels that compute
777-
// to years past 9999. time.Time.MarshalJSON would crash on those;
778-
// the helper must defensively return zero so JSON export works.
779762
jsonBytes, err := timeEpoch(1 << 62).MarshalJSON()
780763
require.NoError(t, err)
781764
assert.JSONEq(t, `"0001-01-01T00:00:00Z"`, string(jsonBytes))

browser/firefox/firefox_test.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,7 @@ func TestExtractCategory(t *testing.T) {
317317
})
318318
}
319319

320-
// ---------------------------------------------------------------------------
321-
// firefoxMicros / firefoxMillis / firefoxSeconds
322-
// ---------------------------------------------------------------------------
323-
324-
// Anchor: 2024-01-15T10:30:00Z → Unix seconds 1705314600.
320+
// Anchor: 2024-01-15T10:30:00Z.
325321
const anchorUnixSeconds = int64(1705314600)
326322

327323
func TestFirefoxMicros_AnchorDate(t *testing.T) {
@@ -331,7 +327,6 @@ func TestFirefoxMicros_AnchorDate(t *testing.T) {
331327
}
332328

333329
func TestFirefoxMicros_PrecisionPreserved(t *testing.T) {
334-
// 123456 μs past the anchor — the sub-second portion must survive.
335330
got := firefoxMicros(anchorUnixSeconds*1_000_000 + 123456)
336331
assert.Equal(t, 123456*int64(time.Microsecond), int64(got.Nanosecond()))
337332
}
@@ -366,16 +361,13 @@ func TestFirefoxHelpers_NegativeReturnsZeroTime(t *testing.T) {
366361
}
367362

368363
func TestFirefoxHelpers_AlwaysUTC(t *testing.T) {
369-
// Verify no helper leaks time.Local, regardless of runner TZ.
370364
t.Setenv("TZ", "Asia/Shanghai")
371365
assert.Equal(t, time.UTC, firefoxMicros(anchorUnixSeconds*1_000_000).Location())
372366
assert.Equal(t, time.UTC, firefoxMillis(anchorUnixSeconds*1_000).Location())
373367
assert.Equal(t, time.UTC, firefoxSeconds(anchorUnixSeconds).Location())
374368
}
375369

376370
func TestFirefoxHelpers_SameMomentAcrossUnits(t *testing.T) {
377-
// The same wall-clock instant, expressed in three units, must
378-
// produce three equal time.Time values (no unit confusion).
379371
us := firefoxMicros(anchorUnixSeconds * 1_000_000)
380372
ms := firefoxMillis(anchorUnixSeconds * 1_000)
381373
s := firefoxSeconds(anchorUnixSeconds)
@@ -384,10 +376,6 @@ func TestFirefoxHelpers_SameMomentAcrossUnits(t *testing.T) {
384376
}
385377

386378
func TestFirefoxHelpers_OutOfJSONRangeReturnsZero(t *testing.T) {
387-
// Cookie expiry is occasionally set to INT64_MAX meaning "never";
388-
// without the clamp, time.Time.MarshalJSON would crash at export.
389-
// All three helpers must return the zero time for such input, so
390-
// JSON round-trip just yields "0001-01-01T00:00:00Z".
391379
for _, tc := range []struct {
392380
name string
393381
got time.Time

browser/safari/safari_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,7 @@ func TestExtractCategory(t *testing.T) {
336336
})
337337
}
338338

339-
// ---------------------------------------------------------------------------
340-
// coredataTimestamp
341-
// ---------------------------------------------------------------------------
342-
343-
// Anchor: 2024-01-15T10:30:00Z = Unix 1705314600, which is
344-
// 1705314600 - 978307200 seconds past the Core Data epoch (2001-01-01Z).
339+
// Anchor: 2024-01-15T10:30:00Z, in seconds past the Core Data epoch (2001-01-01Z).
345340
const anchorCoreDataSeconds = 1705314600 - 978307200
346341

347342
func TestCoredataTimestamp_AnchorDate(t *testing.T) {
@@ -351,8 +346,6 @@ func TestCoredataTimestamp_AnchorDate(t *testing.T) {
351346
}
352347

353348
func TestCoredataTimestamp_EpochZero(t *testing.T) {
354-
// Core Data "distant past" sentinel (0 seconds) maps to the zero
355-
// time.Time rather than silently returning 2001-01-01.
356349
assert.True(t, coredataTimestamp(0).IsZero())
357350
}
358351

@@ -361,8 +354,6 @@ func TestCoredataTimestamp_NegativeReturnsZeroTime(t *testing.T) {
361354
}
362355

363356
func TestCoredataTimestamp_FractionalSecondsPreserved(t *testing.T) {
364-
// Core Data is a floating-point double, so fractional seconds are
365-
// real. 0.5s fraction must survive, not silently truncate.
366357
got := coredataTimestamp(float64(anchorCoreDataSeconds) + 0.5)
367358
assert.Equal(t, 500*int64(time.Millisecond), int64(got.Nanosecond()))
368359
}

0 commit comments

Comments
 (0)