From 7c0dc519e15662255f6f476de31de2f41d82dbef Mon Sep 17 00:00:00 2001 From: polykernel <81340136+polykernel@users.noreply.github.com> Date: Sat, 1 Jan 2022 22:28:45 -0500 Subject: [PATCH] bottom: fix empty-settings test on darwin (#2603) The empty configuration test for the bottom module introduced as of https://github.com/nix-community/home-manager/pull/2323 is not cross platform. Specifically, it silently fails under a darwin environment due to the configuration file not being generated at $XDG_CONFIG_HOME. This PR add cross platform support by specifying the platform-dependent configuration directories to check. The expected unit test data was also extracted to a separate file to differentiate between test data changes and changes to the test itself. --- tests/modules/programs/bottom/empty-settings.nix | 9 +++++++-- .../programs/bottom/example-settings-expected.toml | 6 ++++++ tests/modules/programs/bottom/example-settings.nix | 11 +---------- 3 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 tests/modules/programs/bottom/example-settings-expected.toml diff --git a/tests/modules/programs/bottom/empty-settings.nix b/tests/modules/programs/bottom/empty-settings.nix index 71799c83..15c03c11 100644 --- a/tests/modules/programs/bottom/empty-settings.nix +++ b/tests/modules/programs/bottom/empty-settings.nix @@ -9,8 +9,13 @@ with lib; package = config.lib.test.mkStubPackage { }; }; - nmt.script = '' - assertPathNotExists home-files/.config/bottom + nmt.script = let + configDir = if pkgs.stdenv.isDarwin then + "home-files/Library/Application Support" + else + "home-files/.config"; + in '' + assertPathNotExists ${configDir}/bottom ''; }; } diff --git a/tests/modules/programs/bottom/example-settings-expected.toml b/tests/modules/programs/bottom/example-settings-expected.toml new file mode 100644 index 00000000..019a1825 --- /dev/null +++ b/tests/modules/programs/bottom/example-settings-expected.toml @@ -0,0 +1,6 @@ +[colors] +low_battery_color = "red" + +[flags] +avg_cpu = true +temperature_type = "c" diff --git a/tests/modules/programs/bottom/example-settings.nix b/tests/modules/programs/bottom/example-settings.nix index 30d8e21b..1777b526 100644 --- a/tests/modules/programs/bottom/example-settings.nix +++ b/tests/modules/programs/bottom/example-settings.nix @@ -26,16 +26,7 @@ with lib; in '' assertFileContent \ "${configDir}/bottom/bottom.toml" \ - ${ - builtins.toFile "example-settings-expected.toml" '' - [colors] - low_battery_color = "red" - - [flags] - avg_cpu = true - temperature_type = "c" - '' - } + ${./example-settings-expected.toml} ''; }; }