Add overlapping (consistent) flake cache insert test

* Additionally, update `insert`'s input type hint to support None values
  (as they are already selectable and (one shot) insertable).
  This is necessary to appease the linter wrt the added test.
This commit is contained in:
Jonathan Thiessen
2025-03-24 10:26:29 -07:00
committed by tangential
parent c6698e8a1f
commit d4fa480262
2 changed files with 11 additions and 1 deletions

View File

@@ -154,7 +154,9 @@ class FlakeCacheEntry:
self.value = value
def insert(
self, value: str | float | dict[str, Any] | list[Any], selectors: list[Selector]
self,
value: str | float | dict[str, Any] | list[Any] | None,
selectors: list[Selector],
) -> None:
selector: Selector
if selectors == []:

View File

@@ -17,6 +17,14 @@ def test_select() -> None:
assert not test_cache.is_cached(["x", "z", 1])
def test_insert() -> None:
test_cache = FlakeCacheEntry({}, [])
# Inserting the same thing twice should succeed
test_cache.insert(None, ["nix"])
test_cache.insert(None, ["nix"])
assert test_cache.select(["nix"]) is None
def test_out_path() -> None:
testdict = {"x": {"y": [123, 345, 456], "z": "/nix/store/bla"}}
test_cache = FlakeCacheEntry(testdict, [])