mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2026-02-02 03:15:12 +01:00
feat: add support for running NixOS VM tests more easily
This commit is contained in:
parent
f8fa0846ce
commit
c64e0cce0c
4 changed files with 139 additions and 24 deletions
33
tests/fixtures/sample_test.nix
vendored
33
tests/fixtures/sample_test.nix
vendored
|
|
@ -49,6 +49,39 @@
|
|||
grep -q "test" ${builtins.toFile "test" "test"}
|
||||
'';
|
||||
}
|
||||
{
|
||||
name = "test-vm";
|
||||
type = "vm";
|
||||
vmConfig = {
|
||||
nodes.machine = {pkgs, ...}: {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."localhost" = {
|
||||
root = pkgs.writeTextDir "index.html" "Hello from nixtest VM!";
|
||||
};
|
||||
};
|
||||
};
|
||||
testScript =
|
||||
# py
|
||||
''
|
||||
machine.wait_for_unit("nginx.service")
|
||||
machine.wait_for_open_port(80)
|
||||
machine.succeed("curl -f http://localhost | grep 'Hello from nixtest VM!'")
|
||||
'';
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "vm-fail";
|
||||
type = "vm";
|
||||
vmConfig = {
|
||||
nodes.machine = {};
|
||||
testScript =
|
||||
# py
|
||||
''
|
||||
machine.succeed("curl -f http://localhost | grep 'Hello from nixtest VM!'")
|
||||
'';
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
"other-suite".tests = [
|
||||
|
|
|
|||
|
|
@ -89,9 +89,10 @@
|
|||
assert "-f junit2.xml" "should create junit2.xml"
|
||||
assert_not_contains "$output" "executable file not found" "nix should now exist"
|
||||
assert_contains "$output" "suite-one" "should contain suite-one"
|
||||
assert_contains "$output" "8/11 (1 SKIPPED)" "should be 8/11 total"
|
||||
assert_contains "$output" "9/13 (1 SKIPPED)" "should be 9/13 total"
|
||||
assert_contains "$output" "ERROR" "should contain an error"
|
||||
assert_contains "$output" "SKIP" "should contain a skip"
|
||||
assert_contains "$output" "RequestedAssertionFailed" "vm-fail test should fail"
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue