diff --git a/tests/functional/local-store.sh b/tests/functional/local-store.sh deleted file mode 100644 index e3f0d771c..000000000 --- a/tests/functional/local-store.sh +++ /dev/null @@ -1,25 +0,0 @@ -source common.sh - -cd $TEST_ROOT - -echo example > example.txt -mkdir -p ./x - -NIX_STORE_DIR=$TEST_ROOT/x - -CORRECT_PATH=$(nix-store --store ./x --add example.txt) - -PATH1=$(nix path-info --store ./x $CORRECT_PATH) -[ $CORRECT_PATH == $PATH1 ] - -PATH2=$(nix path-info --store "$PWD/x" $CORRECT_PATH) -[ $CORRECT_PATH == $PATH2 ] - -PATH3=$(nix path-info --store "local?root=$PWD/x" $CORRECT_PATH) -[ $CORRECT_PATH == $PATH3 ] - -# Ensure store ping trusted works with local store -nix --store ./x store ping --json | jq -e '.trusted' - -# Suppress grumpiness about multiple nixes on PATH -(nix --store ./x doctor || true) 2>&1 | grep 'You are trusted by' diff --git a/tests/functional/meson.build b/tests/functional/meson.build index b9979f121..7b42b4943 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -84,7 +84,6 @@ functional_tests_scripts = [ 'logging.sh', 'export.sh', 'config.sh', - 'local-store.sh', 'filter-source.sh', 'misc.sh', 'linux-sandbox.sh', diff --git a/tests/functional2/store/test_local_store.py b/tests/functional2/store/test_local_store.py new file mode 100644 index 000000000..00af28142 --- /dev/null +++ b/tests/functional2/store/test_local_store.py @@ -0,0 +1,45 @@ +from pathlib import Path +import pytest + +from testlib.fixtures.nix import Nix +from testlib.fixtures.file_helper import File, with_files + + +@with_files({"example.txt": File("example")}) +class TestLocalStore: + @pytest.fixture(autouse=True) + def setup(self, nix: Nix, files: Path): # noqa: ARG002 + nix.settings.add_xp_feature("nix-command") + + store = nix.env.dirs.home / "x" + store.mkdir() + nix.env.dirs.nix_store_dir = store + nix.env.dirs.real_store_dir = store + + self.path = ( + nix.nix_store(["--store", "./x", "--add", "example.txt"]).run().ok().stdout_plain + ) + + def test_path_info_relative(self, nix: Nix): + store = "./x" + path = nix.nix(["path-info", "--store", store, self.path]).run().ok().stdout_plain + assert path == self.path + + def test_path_info_absolute(self, nix: Nix): + store = f"{nix.env.dirs.home}/x" + path = nix.nix(["path-info", "--store", store, self.path]).run().ok().stdout_plain + assert path == self.path + + def test_path_info_uri(self, nix: Nix): + store = f"local?root={nix.env.dirs.home}/x" + path = nix.nix(["path-info", "--store", store, self.path]).run().ok().stdout_plain + assert path == self.path + + def test_local_is_trusted(self, nix: Nix): + info = nix.nix(["--store", "./x", "store", "ping", "--json"]).run().json() + assert info["trusted"] + + def test_doctor_shows_trust(self, nix: Nix): + # doctor wants nix-env on path, and the profile lookup test will *always* fail + result = nix.nix(["--store", "./x", "doctor"]).run().expect(2) + assert "You are trusted by" in result.stderr_plain