tests: add example scenario customTest
This commit is contained in:
parent
9e30d2728b
commit
dc0710f3f4
@ -335,6 +335,31 @@ let
|
|||||||
# See ./lib/test-lib.nix for a description
|
# See ./lib/test-lib.nix for a description
|
||||||
test.container.exposeLocalhost = true;
|
test.container.exposeLocalhost = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
## Scenarios with a custom Python test
|
||||||
|
|
||||||
|
# Variant 1: Define testing code that always runs
|
||||||
|
customTestSimple = {
|
||||||
|
networking.hostName = "myhost";
|
||||||
|
|
||||||
|
# Variant 1: Define testing code that always runs
|
||||||
|
test.extraTestScript = ''
|
||||||
|
succeed("[[ $(hostname) == myhost ]]")
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# Variant 2: Define a test that can be enabled/disabled
|
||||||
|
# via the Nix module system.
|
||||||
|
customTestExtended = {
|
||||||
|
networking.hostName = "myhost";
|
||||||
|
|
||||||
|
tests.hostName = true;
|
||||||
|
test.extraTestScript = ''
|
||||||
|
@test("hostName")
|
||||||
|
def _():
|
||||||
|
succeed("[[ $(hostname) == myhost ]]")
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
inherit scenarios;
|
inherit scenarios;
|
||||||
|
Loading…
Reference in New Issue
Block a user