From a018f44c9132ffa5c7b987369010868d0bc95c74 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 11 Nov 2026 21:25:03 +0000 Subject: tests: add NixOS VM tests for populate tests/default.nix provides one VM test per source type, and one for features spanning sources. Each test runs scenarios from tests/scenarios.nix, which cover every combination of a source type's options, deployed to the deploying machine itself, to a remote target as root, and to a remote target using sudo. A scenario prepares the target directory, deploys, checks the result, and deploys and checks again. Scenarios expecting populate to fail check its error message, or check at evaluation time if populate is expected not to evaluate. The deploying machine creates fixtures using tests/fixtures.sh and serves them via HTTP and git daemon, so flakes can be fetched on the target without further network access. Checks evaluate delivered flakes without network access to the fixtures after collecting garbage, so they verify that the delivered store paths are complete and rooted. --- tests/default.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/default.nix (limited to 'tests/default.nix') diff --git a/tests/default.nix b/tests/default.nix new file mode 100644 index 0000000..e9ea769 --- /dev/null +++ b/tests/default.nix @@ -0,0 +1,24 @@ +# NixOS VM tests for populate, one test per source type, plus one for +# features spanning sources. Build all with nix-build tests, or one with, +# e.g., nix-build tests -A flake. +{ pkgs ? import ../pkgs {} }: + +let + # HEAD of /fixtures/gitsrc, which fixtures.sh creates deterministically. + # fixtures.sh fails if it differs, naming the actual one. + gitHead = "e42d44ef9cdb76ba5a84dff4c89c38222703bf0c"; + + scenarios = import ./scenarios.nix { + inherit (pkgs) lib; + krops = import ../lib; + inherit (pkgs) populate; + url = "http://deployer:8000"; + gitUrl = "git://deployer/gitsrc.git"; + remoteHost = "target"; + agePath = "${pkgs.age}/bin/age"; + inherit gitHead; + }; +in + builtins.mapAttrs + (name: scenarios: import ./vm.nix { inherit pkgs name scenarios gitHead; }) + scenarios -- cgit v1.3.1