1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

tests: allow testing assertions

By default tests are expected to produce no assertion.

This also updates the existing tests to match.
This commit is contained in:
Robert Helgesson 2021-02-07 21:52:16 +01:00
parent bdee1be7b3
commit ef4370bedc
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
22 changed files with 102 additions and 85 deletions

View file

@ -19,6 +19,22 @@ with lib;
'';
};
};
assertions = {
enable = mkOption {
type = types.bool;
default = true;
description = "Whether assertion asserts are enabled.";
};
expected = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
List of expected assertions.
'';
};
};
};
config = mkIf config.test.asserts.warnings.enable {
@ -27,6 +43,11 @@ with lib;
--
'' config.warnings;
"asserts/assertions.actual".text = concatStringsSep ''
--
'' (map (x: x.message) (filter (x: !x.assertion) config.assertions));
};
nmt.script = ''
@ -38,6 +59,15 @@ with lib;
--
'' config.test.asserts.warnings.expected)
}
assertFileContent \
home-files/asserts/assertions.actual \
${
pkgs.writeText "assertions.expected" (concatStringsSep ''
--
'' config.test.asserts.assertions.expected)
}
'';
};
}