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:
parent
bdee1be7b3
commit
ef4370bedc
22 changed files with 102 additions and 85 deletions
|
|
@ -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)
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue