Add basic unit test that evlauates the module

This commit is contained in:
Tim Van Baak 2022-12-28 15:43:15 -08:00
parent d9a5f6b7c2
commit c1e27b73b0
2 changed files with 26 additions and 2 deletions

View File

@ -39,6 +39,30 @@
''; '';
}; };
}; };
checks.${system}.test-module = let
test-lib = import "${nixpkgs}/nixos/lib/testing-python.nix" {
inherit system;
};
in
test-lib.makeTest {
name = "inquisitor-test-module";
nodes = {
host = { ... }: {
imports = [ self.nixosModules.default ];
services.inquisitor.enable = true;
};
};
testScript = ''
start_all()
host.wait_for_unit("multi-user.target")
# Check that the setup script ran
host.succeed("[ -e /var/lib/inquisitor ]")
# Check that the service came up
host.succeed("systemctl is-enabled inquisitor")
host.succeed("systemctl is-active inquisitor")
'';
};
}; };
in (my-flake.outputs-for each systems) // { in (my-flake.outputs-for each systems) // {
overlays.default = final: prev: { overlays.default = final: prev: {

View File

@ -31,7 +31,7 @@ in
config = config =
let let
# Get the inquisitor package from the flake. # Get the inquisitor package from the flake.
inquisitor = flake.packages.${pkgs.stdenv.hostPlatform.system}.default; inquisitor = flake.packages.${pkgs.stdenv.hostPlatform.system}.env;
# Define the inquisitor state directory. # Define the inquisitor state directory.
stateDir = "/var/lib/inquisitor"; stateDir = "/var/lib/inquisitor";
@ -80,7 +80,7 @@ in
if [ -f ${stateDir}/scp-helper ]; then if [ -f ${stateDir}/scp-helper ]; then
${pkgs.coreutils}/bin/rm ${stateDir}/scp-helper ${pkgs.coreutils}/bin/rm ${stateDir}/scp-helper
fi fi
ln -s -t ${stateDir}/scp-helper ${scp-helper}/bin/scp-helper ln -s -t ${stateDir} ${scp-helper}/bin/scp-helper
''; '';
# Create a run script for the service. # Create a run script for the service.