mirror of
https://github.com/RGBCube/hjem
synced 2025-10-13 13:12:16 +00:00
modules/xdg: overhaul tests
This commit is contained in:
parent
5c81ae5840
commit
a4c1bff70a
2 changed files with 41 additions and 26 deletions
|
@ -12,6 +12,7 @@ in
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
|
||||
xdg = {
|
||||
clobber,
|
||||
|
@ -21,7 +22,7 @@ in
|
|||
directory = mkIf altLocation (userHome + "/customCacheDirectory");
|
||||
files = {
|
||||
"foo" = {
|
||||
text = "Hello world!";
|
||||
text = "Hello ${optionalString clobber "new "}world!";
|
||||
inherit clobber;
|
||||
};
|
||||
};
|
||||
|
@ -31,7 +32,7 @@ in
|
|||
files = {
|
||||
"bar.json" = {
|
||||
generator = lib.generators.toJSON {};
|
||||
value = {bar = true;};
|
||||
value = {bar = "Hello ${optionalString clobber "new "}second world!";};
|
||||
inherit clobber;
|
||||
};
|
||||
};
|
||||
|
@ -41,7 +42,7 @@ in
|
|||
files = {
|
||||
"baz.toml" = {
|
||||
generator = (pkgs.formats.toml {}).generate "baz.toml";
|
||||
value = {baz = true;};
|
||||
value = {baz = "Hello ${optionalString clobber "new "}third world!";};
|
||||
inherit clobber;
|
||||
};
|
||||
};
|
||||
|
@ -50,7 +51,7 @@ in
|
|||
directory = mkIf altLocation (userHome + "/customStateDirectory");
|
||||
files = {
|
||||
"foo" = {
|
||||
source = pkgs.writeText "file-bar" "Hello World!";
|
||||
source = pkgs.writeText "file-bar" "Hello ${optionalString clobber "new "}fourth world!";
|
||||
inherit clobber;
|
||||
};
|
||||
};
|
||||
|
@ -95,7 +96,6 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
altFilesGetOverwritten.configuration = {
|
||||
hjem.users.alice = {
|
||||
files.".config/foo" = {
|
||||
|
@ -123,28 +123,41 @@ in
|
|||
with subtest("Default file locations get liked"):
|
||||
node1.succeed("${specialisations}/defaultFilesGetLinked/bin/switch-to-configuration test")
|
||||
node1.succeed("test -L ${userHome}/.cache/foo")
|
||||
node1.succeed("grep \"Hello world!\" ~alice/.cache/foo")
|
||||
node1.succeed("test -L ${userHome}/.config/bar.json")
|
||||
node1.succeed("grep \"Hello second world!\" ~alice/.config/bar.json")
|
||||
node1.succeed("test -L ${userHome}/.local/share/baz.toml")
|
||||
node1.succeed("grep \"Hello third world!\" ~alice/.local/share/baz.toml")
|
||||
node1.succeed("test -L ${userHome}/.local/state/foo")
|
||||
node1.succeed("grep \"Hello fourth world!\" ~alice/.local/state/foo")
|
||||
|
||||
with subtest("Alternate file locations get linked"):
|
||||
node1.succeed("${specialisations}/altFilesGetLinked/bin/switch-to-configuration test")
|
||||
node1.succeed("test -L ${userHome}/customCacheDirectory/foo")
|
||||
node1.succeed("grep \"Hello world!\" ~alice/customCacheDirectory/foo")
|
||||
node1.succeed("test -L ${userHome}/customConfigDirectory/bar.json")
|
||||
node1.succeed("grep \"Hello second world!\" ~alice/customConfigDirectory/bar.json")
|
||||
node1.succeed("test -L ${userHome}/customDataDirectory/baz.toml")
|
||||
node1.succeed("grep \"Hello third world!\" ~alice/customDataDirectory/baz.toml")
|
||||
node1.succeed("test -L ${userHome}/customStateDirectory/foo")
|
||||
node1.succeed("grep \"Hello fourth world!\" ~alice/customStateDirectory/foo")
|
||||
# Same name as config test file to verify proper merging
|
||||
node1.succeed("test -L ${userHome}/.config/foo")
|
||||
node1.succeed("grep \"Hello world!\" ${userHome}/.config/foo")
|
||||
node1.succeed("grep \"Hello world!\" ~alice/.config/foo")
|
||||
|
||||
with subtest("Alternate file locations get overwritten when changed"):
|
||||
node1.succeed("${specialisations}/altFilesGetLinked/bin/switch-to-configuration test")
|
||||
node1.succeed("${specialisations}/altFilesGetOverwritten/bin/switch-to-configuration test")
|
||||
node1.succeed("test -L ${userHome}/customCacheDirectory/foo")
|
||||
node1.succeed("grep \"Hello new world!\" ~alice/customCacheDirectory/foo")
|
||||
node1.succeed("test -L ${userHome}/customConfigDirectory/bar.json")
|
||||
node1.succeed("grep \"Hello new second world!\" ~alice/customConfigDirectory/bar.json")
|
||||
node1.succeed("test -L ${userHome}/customDataDirectory/baz.toml")
|
||||
node1.succeed("grep \"Hello new third world!\" ~alice/customDataDirectory/baz.toml")
|
||||
node1.succeed("test -L ${userHome}/customStateDirectory/foo")
|
||||
node1.succeed("grep \"Hello new fourth world!\" ~alice/customStateDirectory/foo")
|
||||
# Same name as config test file to verify proper merging
|
||||
node1.succeed("test -L ${userHome}/.config/foo")
|
||||
node1.succeed("grep \"Hello new world!\" ${userHome}/.config/foo")
|
||||
node1.succeed("grep \"Hello new world!\" ~alice/.config/foo")
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -23,9 +23,8 @@ in
|
|||
alice = {
|
||||
enable = true;
|
||||
files = {
|
||||
"bar.json" = {
|
||||
generator = (pkgs.formats.toml {}).generate "baz.toml";
|
||||
value = {baz = true;};
|
||||
"foo" = {
|
||||
text = "Hello world!";
|
||||
};
|
||||
};
|
||||
xdg = {
|
||||
|
@ -42,7 +41,7 @@ in
|
|||
files = {
|
||||
"bar.json" = {
|
||||
generator = lib.generators.toJSON {};
|
||||
value = {bar = true;};
|
||||
value = {bar = "Hello second world!";};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -51,7 +50,7 @@ in
|
|||
files = {
|
||||
"baz.toml" = {
|
||||
generator = (pkgs.formats.toml {}).generate "baz.toml";
|
||||
value = {baz = true;};
|
||||
value = {baz = "Hello third world!";};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -59,7 +58,7 @@ in
|
|||
directory = userHome + "/customStateDirectory";
|
||||
files = {
|
||||
"foo" = {
|
||||
source = pkgs.writeText "file-bar" "Hello World!";
|
||||
source = pkgs.writeText "file-bar" "Hello fourth world!";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -84,20 +83,23 @@ in
|
|||
machine.succeed("loginctl enable-linger alice")
|
||||
machine.wait_until_succeeds("systemctl --user --machine=alice@ is-active systemd-tmpfiles-setup.service")
|
||||
|
||||
|
||||
# Test XDG files created by Hjem
|
||||
machine.succeed("[ -L ~alice/customCacheDirectory/foo ]")
|
||||
machine.succeed("[ -L ~alice/customConfigDirectory/bar.json ]")
|
||||
machine.succeed("[ -L ~alice/customDataDirectory/baz.toml ]")
|
||||
# Same name as config test file to verify proper merging
|
||||
machine.succeed("[ -L ~alice/customStateDirectory/foo ]")
|
||||
with subtest("XDG files created by Hjem"):
|
||||
machine.succeed("[ -L ~alice/customCacheDirectory/foo ]")
|
||||
machine.succeed("grep \"Hello world!\" ~alice/customCacheDirectory/foo")
|
||||
machine.succeed("[ -L ~alice/customConfigDirectory/bar.json ]")
|
||||
machine.succeed("grep \"Hello second world!\" ~alice/customConfigDirectory/bar.json")
|
||||
machine.succeed("[ -L ~alice/customDataDirectory/baz.toml ]")
|
||||
machine.succeed("grep \"Hello third world!\" ~alice/customDataDirectory/baz.toml")
|
||||
# Same name as config test file to verify proper merging
|
||||
machine.succeed("[ -L ~alice/customStateDirectory/foo ]")
|
||||
machine.succeed("grep \"Hello fourth world!\" ~alice/customStateDirectory/foo")
|
||||
|
||||
|
||||
# Basic test file created by Hjem
|
||||
# Same name as cache test file to verify proper merging
|
||||
machine.succeed("[ -L ~alice/bar.json ]")
|
||||
# Test regular files, created by systemd-tmpfiles
|
||||
machine.succeed("[ -d ~alice/user_tmpfiles_created ]")
|
||||
machine.succeed("[ -d ~alice/only_alice ]")
|
||||
with subtest("Basic test file for Hjem"):
|
||||
machine.succeed("[ -L ~alice/foo ]") # Same name as cache test file to verify proper merging
|
||||
machine.succeed("grep \"Hello world!\" ~alice/foo")
|
||||
# Test regular files, created by systemd-tmpfiles
|
||||
machine.succeed("[ -d ~alice/user_tmpfiles_created ]")
|
||||
machine.succeed("[ -d ~alice/only_alice ]")
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue