Files
lix/tests/functional2/flakes/test_run.py
T
eldritch horrors ff8a10f9cd testing: move shell-hello.nix from global assets to flakes
Change-Id: I0039e82cd5ed069d901f4dd96cf33102216a11ea
2026-02-21 16:36:44 +00:00

40 lines
1.2 KiB
Python

from testlib.fixtures.nix import Nix
from testlib.fixtures.file_helper import with_files
from testlib.utils import get_global_asset, CopyTemplate, CopyFile
from testlib.environ import environ
import pytest
@with_files(
{
"shell-hello.nix": CopyFile("assets/shell-hello.nix"),
"config.nix": get_global_asset("config.nix"),
"flake.nix": CopyTemplate("assets/run/flake.nix", {"system": environ.get("system")}),
}
)
class TestFlakeRun:
@pytest.mark.parametrize("attr", ["appAsApp", "pkgAsPkg"])
def test_run_succeeds(self, nix: Nix, attr: str):
assert (
"Hello World"
in nix.nix(["run", "--no-write-lock-file", f".#{attr}"], flake=True).run().ok().stdout_s
)
def test_run_pkg_as_app(self, nix: Nix):
assert (
"should have type 'derivation'"
in nix.nix(["run", "--no-write-lock-file", ".#pkgAsApp"], flake=True)
.run()
.expect(1)
.stderr_s
)
def test_run_app_as_pkg(self, nix: Nix):
assert (
"should have type 'app'"
in nix.nix(["run", "--no-write-lock-file", ".#appAsPkg"], flake=True)
.run()
.expect(1)
.stderr_s
)