Files
lix/tests/functional2/eval/test_to_string.py
T
rootile a99b6f18c8 f2: migrate toString-path.sh
Change-Id: I862f532e94e385aa0f14c03e38e7e003c7bc83c3
2026-02-09 15:37:41 +01:00

41 lines
1.1 KiB
Python

from testlib.fixtures.file_helper import with_files, File
from testlib.fixtures.nix import Nix
@with_files({"foo": {"bar": File("bla")}})
def test_path_read_file(nix: Nix):
nix.settings.add_xp_feature("nix-command", "flakes")
res = (
nix.nix(
[
"eval",
"--raw",
"--impure",
"--expr",
f'builtins.readFile (builtins.toString (builtins.fetchTree {{ type = "path"; path = "{nix.env.dirs.home / "foo"}"; }} + "/bar"))',
]
)
.run()
.ok()
)
assert res.stdout_plain == "bla"
@with_files({"foo": {"bar": File("bla")}})
def test_path_read_dir(nix: Nix):
nix.settings.add_xp_feature("nix-command", "flakes")
res = (
nix.nix(
[
"eval",
"--json",
"--impure",
"--expr",
f'builtins.readDir (builtins.toString (builtins.fetchTree {{ type = "path"; path = "{nix.env.dirs.home / "foo"}"; }}))',
]
)
.run()
.ok()
)
assert res.stdout_plain == '{"bar":"regular"}'