diff --git a/tests/asserts.nix b/tests/asserts.nix new file mode 100644 index 000000000..e6813b289 --- /dev/null +++ b/tests/asserts.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + options.test.asserts = { + warnings = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether warning asserts are enabled."; + }; + + expected = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + List of expected warnings. + ''; + }; + }; + }; + + config = mkIf config.test.asserts.warnings.enable { + home.file = { + "asserts/warnings.actual".text = concatStringsSep '' + + -- + '' config.warnings; + }; + + nmt.script = '' + assertFileContent \ + home-files/asserts/warnings.actual \ + ${ + pkgs.writeText "warnings.expected" (concatStringsSep '' + + -- + '' config.test.asserts.warnings.expected) + } + ''; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 3905f654c..33a22e2ba 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -25,6 +25,8 @@ let # Avoid including documentation since this will cause # unnecessary rebuilds of the tests. manual.manpages.enable = false; + + imports = [ ./asserts.nix ]; } ]; diff --git a/tests/modules/programs/git/git-with-str-extra-config.nix b/tests/modules/programs/git/git-with-str-extra-config.nix index 3dbc497a5..b2294c65b 100644 --- a/tests/modules/programs/git/git-with-str-extra-config.nix +++ b/tests/modules/programs/git/git-with-str-extra-config.nix @@ -14,6 +14,12 @@ with lib; userName = "John Doe"; }; + test.asserts.warnings.expected = ['' + Using programs.git.extraConfig as a string option is + deprecated and will be removed in the future. Please + change to using it as an attribute set instead. + '']; + nmt.script = '' assertFileExists home-files/.config/git/config assertFileContent home-files/.config/git/config \ diff --git a/tests/modules/programs/lieer/lieer.nix b/tests/modules/programs/lieer/lieer.nix index 2ce4fb4e0..e0ade636b 100644 --- a/tests/modules/programs/lieer/lieer.nix +++ b/tests/modules/programs/lieer/lieer.nix @@ -8,7 +8,10 @@ with lib; config = { programs.lieer.enable = true; - accounts.email.accounts = { "hm@example.com".lieer.enable = true; }; + accounts.email.accounts."hm@example.com" = { + lieer.enable = true; + notmuch.enable = true; + }; nixpkgs.overlays = [ (self: super: { gmailieer = pkgs.writeScriptBin "dummy-gmailieer" ""; }) diff --git a/tests/modules/programs/waybar/broken-settings.nix b/tests/modules/programs/waybar/broken-settings.nix index f5ac39468..d0e131501 100644 --- a/tests/modules/programs/waybar/broken-settings.nix +++ b/tests/modules/programs/waybar/broken-settings.nix @@ -66,6 +66,10 @@ in { }]; }; + # Remove when https://github.com/nix-community/home-manager/issues/1686 is + # fixed. + test.asserts.warnings.enable = false; + nmt.description = '' Test for the broken configuration https://github.com/nix-community/home-manager/pull/1329#issuecomment-653253069 diff --git a/tests/modules/programs/waybar/settings-complex.nix b/tests/modules/programs/waybar/settings-complex.nix index 1756ae120..16ceccb6a 100644 --- a/tests/modules/programs/waybar/settings-complex.nix +++ b/tests/modules/programs/waybar/settings-complex.nix @@ -50,6 +50,10 @@ in { }]; }; + # Remove when https://github.com/nix-community/home-manager/issues/1686 is + # fixed. + test.asserts.warnings.enable = false; + nmt.script = '' assertPathNotExists home-files/.config/waybar/style.css assertFileContent \ diff --git a/tests/modules/services/lieer/lieer-service.nix b/tests/modules/services/lieer/lieer-service.nix index 03dcdc749..60e00e0cc 100644 --- a/tests/modules/services/lieer/lieer-service.nix +++ b/tests/modules/services/lieer/lieer-service.nix @@ -11,6 +11,7 @@ with lib; accounts.email.accounts = { "hm@example.com".lieer.enable = true; "hm@example.com".lieer.sync.enable = true; + "hm@example.com".notmuch.enable = true; }; nixpkgs.overlays = [