test(cli/select): add simple caching test

This commit is contained in:
Johannes Kirschbauer
2025-04-16 21:49:09 +02:00
parent 5327c6dcf9
commit 17fb2fc53d

View File

@@ -96,6 +96,25 @@ def test_conditional_all_selector(flake: ClanFlake) -> None:
flake2.prefetch() flake2.prefetch()
# Test that the caching works
@pytest.mark.with_core
def test_caching_works(flake: ClanFlake) -> None:
from unittest.mock import patch
from clan_cli.flake import Flake
my_flake = Flake(str(flake.path))
with patch.object(
my_flake, "get_from_nix", wraps=my_flake.get_from_nix
) as tracked_build:
assert tracked_build.call_count == 0
my_flake.select("clanInternals.inventory.meta")
assert tracked_build.call_count == 1
my_flake.select("clanInternals.inventory.meta")
assert tracked_build.call_count == 1
# This test fails because the CI sandbox does not have the required packages to run the generators # This test fails because the CI sandbox does not have the required packages to run the generators
# maybe @DavHau or @Qubasa can fix this at some point :) # maybe @DavHau or @Qubasa can fix this at some point :)
# @pytest.mark.with_core # @pytest.mark.with_core