From e7407d9efef452567cb731c4b6863fa101b6533f Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sun, 15 Jan 2023 20:27:48 +0100 Subject: [PATCH] tests: add example scenario `customTest` --- test/tests.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/tests.nix b/test/tests.nix index e144509..168c911 100644 --- a/test/tests.nix +++ b/test/tests.nix @@ -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;