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:
committed by
tangential
parent
74fb3abbc7
commit
5e2b5fe213
@@ -154,7 +154,9 @@ class FlakeCacheEntry:
|
|||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
def insert(
|
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:
|
) -> None:
|
||||||
selector: Selector
|
selector: Selector
|
||||||
if selectors == []:
|
if selectors == []:
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ def test_select() -> None:
|
|||||||
assert not test_cache.is_cached(["x", "z", 1])
|
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:
|
def test_out_path() -> None:
|
||||||
testdict = {"x": {"y": [123, 345, 456], "z": "/nix/store/bla"}}
|
testdict = {"x": {"y": [123, 345, 456], "z": "/nix/store/bla"}}
|
||||||
test_cache = FlakeCacheEntry(testdict, [])
|
test_cache = FlakeCacheEntry(testdict, [])
|
||||||
|
|||||||
Reference in New Issue
Block a user