tests: add example scenario customTest

This commit is contained in:
Erik Arvstedt 2023-01-15 20:27:48 +01:00
parent 9e30d2728b
commit dc0710f3f4
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -335,6 +335,31 @@ let
# See ./lib/test-lib.nix for a description
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 {
inherit scenarios;