1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
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
)
|