introduce flake parts module for clan nixos tests

This commit is contained in:
Jörg Thalheim
2025-06-17 18:38:49 +02:00
parent 3ea159721c
commit 7515d54d9e
4 changed files with 116 additions and 48 deletions

View File

@@ -1,6 +1,5 @@
{
self,
inputs,
lib,
...
}:
@@ -14,7 +13,7 @@ in
wifi = module;
};
perSystem =
{ pkgs, ... }:
{ ... }:
{
/**
1. Prepare the test vars
@@ -23,15 +22,10 @@ in
2. To run the test
nix build .#checks.x86_64-linux.hello-service
*/
checks =
# Currently we don't support nixos-integration tests on darwin
lib.optionalAttrs (pkgs.stdenv.isLinux) {
wifi-service = import ./tests/vm/default.nix {
inherit module;
inherit inputs pkgs;
clan-core = self;
nixosLib = import (self.inputs.nixpkgs + "/nixos/lib") { };
};
};
clan.nixosTests.wifi-service = {
imports = [ ./tests/vm/default.nix ];
clan.modules."@clan/wifi" = module;
};
};
}

View File

@@ -1,46 +1,29 @@
{
pkgs,
nixosLib,
clan-core,
module,
...
}:
nixosLib.runTest (
{ ... }:
{
imports = [
clan-core.modules.nixosVmTest.clanTest
];
name = "wifi-service";
hostPkgs = pkgs;
clan = {
directory = ./.;
test.useContainers = false;
inventory = {
name = "wifi-service";
machines.test = { };
clan = {
directory = ./.;
test.useContainers = false;
modules."@clan/wifi" = module;
inventory = {
instances = {
wg-test-one = {
module.name = "@clan/wifi";
machines.test = { };
instances = {
wg-test-one = {
module.name = "@clan/wifi";
roles.default.machines = {
test.settings.networks.one = { };
};
roles.default.machines = {
test.settings.networks.one = { };
};
};
};
};
};
testScript = ''
start_all()
test.wait_for_unit("NetworkManager.service")
psk = test.succeed("cat /run/NetworkManager/system-connections/one.nmconnection")
assert "password-eins" in psk, "Password is incorrect"
'';
}
)
testScript = ''
start_all()
test.wait_for_unit("NetworkManager.service")
psk = test.succeed("cat /run/NetworkManager/system-connections/one.nmconnection")
assert "password-eins" in psk, "Password is incorrect"
'';
}