hello-world: migrate to clan.nixosTests module

This commit is contained in:
Jörg Thalheim
2025-06-17 19:28:12 +02:00
parent 47ac9afe0b
commit 5d4dc437c2
2 changed files with 25 additions and 45 deletions

View File

@@ -14,7 +14,7 @@ in
hello-world = module;
};
perSystem =
{ pkgs, ... }:
{ ... }:
let
# Module that contains the tests
# This module adds:
@@ -41,15 +41,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) {
hello-service = import ./tests/vm/default.nix {
inherit module;
inherit self inputs pkgs;
nixosLib = import (self.inputs.nixpkgs + "/nixos/lib") { };
clan-core = self;
};
};
clan.nixosTests.hello-service = {
imports = [ ./tests/vm/default.nix ];
clan.modules.hello-service = module;
};
};
}

View File

@@ -1,44 +1,29 @@
{
pkgs,
nixosLib,
clan-core,
module,
...
}:
nixosLib.runTest (
{ ... }:
{
imports = [
clan-core.modules.nixosVmTest.clanTest
];
{
name = "hello-service";
hostPkgs = pkgs;
clan = {
directory = ./.;
inventory = {
machines.peer1 = { };
name = "hello-service";
clan = {
directory = ./.;
modules = {
hello-service = module;
};
inventory = {
machines.peer1 = { };
instances."test" = {
module.name = "hello-service";
roles.peer.machines.peer1 = { };
};
instances."test" = {
module.name = "hello-service";
roles.peer.machines.peer1 = { };
};
};
};
testScript =
{ nodes, ... }:
''
start_all()
testScript =
{ nodes, ... }:
''
start_all()
# peer1 should have the 'hello' file
value = peer1.succeed("cat ${nodes.peer1.clan.core.vars.generators.hello.files.hello.path}")
assert value.strip() == "Hello world from peer1", value
'';
}
)
# peer1 should have the 'hello' file
value = peer1.succeed("cat ${nodes.peer1.clan.core.vars.generators.hello.files.hello.path}")
assert value.strip() == "Hello world from peer1", value
'';
}