Skip to content

Commit c8eca78

Browse files
test: make extensive snapshot fixture timestamps monotonic
1 parent 7a31887 commit c8eca78

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/conftest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from collections.abc import Generator
3535
from datetime import date, datetime, timezone
3636
from pathlib import Path
37-
from random import choice, randint
37+
from random import choice
3838
from tempfile import TemporaryDirectory
3939
from typing import (
4040
TYPE_CHECKING,
@@ -815,19 +815,22 @@ def generate_snapshot(
815815
snapshot_log = []
816816
initial_snapshot_id = 3051729675574597004
817817

818+
base_timestamp_ms = 1602638573590
818819
for i in range(2000):
819820
snapshot_id = initial_snapshot_id + i
820821
parent_snapshot_id = snapshot_id - 1 if i > 0 else None
821-
timestamp_ms = int(time.time() * 1000) - randint(0, 1000000)
822+
timestamp_ms = base_timestamp_ms + i
822823
snapshots.append(generate_snapshot(snapshot_id, parent_snapshot_id, timestamp_ms, i))
823824
snapshot_log.append({"snapshot-id": snapshot_id, "timestamp-ms": timestamp_ms})
824825

826+
last_updated_ms = snapshot_log[-1]["timestamp-ms"]
827+
825828
return {
826829
"format-version": 2,
827830
"table-uuid": "9c12d441-03fe-4693-9a96-a0705ddf69c1",
828831
"location": "s3://bucket/test/location",
829832
"last-sequence-number": 34,
830-
"last-updated-ms": 1602638573590,
833+
"last-updated-ms": last_updated_ms,
831834
"last-column-id": 3,
832835
"current-schema-id": 1,
833836
"schemas": [

0 commit comments

Comments
 (0)