1
Fork 0
mirror of https://github.com/RGBCube/hjem synced 2025-10-13 13:12:16 +00:00

tests/linker: test manifest creation

This commit is contained in:
Anthony Rodriguez 2025-05-28 10:46:57 +02:00 committed by éclairevoyant
parent da6dd7db51
commit 3cb5074af0
No known key found for this signature in database
GPG key ID: E3813AEAA02DB54B
2 changed files with 50 additions and 1 deletions

View file

@ -21,12 +21,13 @@
checks = forAllSystems (system: let
checkArgs = {
inherit self;
inherit self inputs;
pkgs = nixpkgs.legacyPackages.${system};
};
in {
hjem-basic = import ./tests/basic.nix checkArgs;
hjem-special-args = import ./tests/special-args.nix checkArgs;
hjem-linker = import ./tests/linker.nix checkArgs;
# Build smfh as a part of 'nix flake check'
smfh = inputs.smfh.packages.${system}.smfh;

48
tests/linker.nix Normal file
View file

@ -0,0 +1,48 @@
let
userHome = "/home/alice";
in
(import ./lib) {
name = "hjem-linker";
nodes = {
node1 = {
self,
pkgs,
inputs,
...
}: {
imports = [self.nixosModules.hjem];
system.switch.enable = true;
users.groups.alice = {};
users.users.alice = {
isNormalUser = true;
home = userHome;
password = "";
};
hjem = {
linker = inputs.smfh.packages.${pkgs.system}.default;
users = {
alice = {
enable = true;
};
};
};
};
};
testScript = {nodes, ...}: let
baseSystem = nodes.node1.system.build.toplevel;
in ''
node1.succeed("loginctl enable-linger alice")
with subtest("Activation service runs correctly"):
node1.succeed("${baseSystem}/bin/switch-to-configuration test")
node1.succeed("systemctl show servicename --property=Result --value | grep -q '^success$'")
with subtest("Manifest gets created"):
node1.succeed("${baseSystem}/bin/switch-to-configuration test")
node1.succeed("[ -f /var/lib/hjem/manifest-alice.json ]")
'';
}