mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 19:49:45 +01:00
043ba285c6
This introduces some rudimentary integration tests using the NixOS test framework. The intent is to better catch regressions when doing more elaborate changes that may affect overall Home Manager behavior. Note, the tests are currently not run automatically.
44 lines
1.4 KiB
Nix
44 lines
1.4 KiB
Nix
{ pkgs, ... }:
|
|
|
|
{
|
|
name = "nixos-basics";
|
|
meta.maintainers = [ pkgs.lib.maintainers.rycee ];
|
|
|
|
nodes.machine = { ... }: {
|
|
imports = [ ../../../nixos ]; # Import the HM NixOS module.
|
|
|
|
users.users.alice = { isNormalUser = true; };
|
|
|
|
home-manager.users.alice = { ... }: {
|
|
home.stateVersion = "23.11";
|
|
home.file.test.text = "testfile";
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
machine.wait_for_unit("home-manager-alice.service")
|
|
|
|
with subtest("Home Manager file"):
|
|
# The file should be linked with the expected content.
|
|
path = "/home/alice/test"
|
|
machine.succeed(f"test -L {path}")
|
|
actual = machine.succeed(f"cat {path}")
|
|
expected = "testfile"
|
|
assert actual == expected, f"expected {path} to contain {expected}, but got {actual}"
|
|
|
|
with subtest("GC root and profile"):
|
|
# There should be a GC root and Home Manager profile and they should point
|
|
# to the same path in the Nix store.
|
|
gcroot = "/home/alice/.local/state/home-manager/gcroots/current-home"
|
|
gcrootTarget = machine.succeed(f"readlink {gcroot}")
|
|
|
|
profile = "/home/alice/.local/state/nix/profiles"
|
|
profileTarget = machine.succeed(f"readlink {profile}/home-manager")
|
|
profile1Target = machine.succeed(f"readlink {profile}/{profileTarget}")
|
|
|
|
assert gcrootTarget == profile1Target, \
|
|
f"expected GC root and profile to point to same, but pointed to {gcrootTarget} and {profile1Target}"
|
|
'';
|
|
}
|