test(ariadne): cover storage snapshot edges
This commit is contained in:
parent
4bbb50f5ad
commit
604b198534
@ -359,8 +359,27 @@ def test_prune_cluster_state_skips_zero() -> None:
|
|||||||
assert not db.executed
|
assert not db.executed
|
||||||
|
|
||||||
|
|
||||||
|
def test_prune_cluster_state_executes_with_positive_keep() -> None:
|
||||||
|
db = DummyDB()
|
||||||
|
storage = Storage(db)
|
||||||
|
|
||||||
|
storage.prune_cluster_state(3)
|
||||||
|
|
||||||
|
assert db.executed[-1][1] == (3,)
|
||||||
|
|
||||||
|
|
||||||
def test_latest_cluster_state_parses_json() -> None:
|
def test_latest_cluster_state_parses_json() -> None:
|
||||||
db = DummyDB(row={"snapshot": "{\"ok\": true}", "created_at": datetime.now()})
|
db = DummyDB(row={"snapshot": "{\"ok\": true}", "created_at": datetime.now()})
|
||||||
storage = Storage(db)
|
storage = Storage(db)
|
||||||
snapshot = storage.latest_cluster_state()
|
snapshot = storage.latest_cluster_state()
|
||||||
assert snapshot == {"ok": True}
|
assert snapshot == {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
|
def test_latest_cluster_state_handles_empty_and_native_snapshots() -> None:
|
||||||
|
assert Storage(DummyDB(row=None)).latest_cluster_state() is None
|
||||||
|
assert Storage(DummyDB(row={"snapshot": {"ok": True}, "created_at": datetime.now()})).latest_cluster_state() == {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
|
def test_latest_cluster_state_rejects_bad_snapshot_payloads() -> None:
|
||||||
|
assert Storage(DummyDB(row={"snapshot": "{bad", "created_at": datetime.now()})).latest_cluster_state() is None
|
||||||
|
assert Storage(DummyDB(row={"snapshot": 42, "created_at": datetime.now()})).latest_cluster_state() is None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user