mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +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)
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
accounts = {
|
||||
"hm@example.com" = {
|
||||
primary = true;
|
||||
address = "hm@example.com";
|
||||
userName = "home.manager";
|
||||
realName = "H. M. Test";
|
||||
|
|
|
@ -8,7 +8,6 @@ with lib;
|
|||
config = {
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
primary = true;
|
||||
notmuch.enable = true;
|
||||
alot = {
|
||||
contactCompletion = { };
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
output DP1
|
||||
off
|
||||
|
||||
output DP2
|
||||
pos 0x0
|
||||
crtc 0
|
||||
primary
|
||||
mode 1920x1080
|
||||
transform 0.600000,0.000000,0.000000,0.000000,0.600000,0.000000,0.000000,0.000000,1.000000
|
||||
scale 2x4
|
|
@ -17,10 +17,6 @@
|
|||
primary = true;
|
||||
position = "0x0";
|
||||
mode = "1920x1080";
|
||||
scale = {
|
||||
x = 2;
|
||||
y = 4;
|
||||
};
|
||||
transform = [
|
||||
[ 0.6 0.0 0.0 ] # a b c
|
||||
[ 0.0 0.6 0.0 ] # d e f
|
||||
|
@ -42,7 +38,18 @@
|
|||
|
||||
assertFileExists $config
|
||||
assertFileContent $config \
|
||||
${./basic-configuration.conf}
|
||||
${
|
||||
pkgs.writeText "basic-configuration.conf" ''
|
||||
output DP1
|
||||
off
|
||||
|
||||
output DP2
|
||||
pos 0x0
|
||||
crtc 0
|
||||
primary
|
||||
mode 1920x1080
|
||||
transform 0.600000,0.000000,0.000000,0.000000,0.600000,0.000000,0.000000,0.000000,1.000000''
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
{ autorandr-basic-configuration = ./basic-configuration.nix; }
|
||||
{
|
||||
autorandr-basic-configuration = ./basic-configuration.nix;
|
||||
autorandr-scale = ./scale.nix;
|
||||
}
|
||||
|
|
32
tests/modules/programs/autorandr/scale.nix
Normal file
32
tests/modules/programs/autorandr/scale.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
programs.autorandr = {
|
||||
enable = true;
|
||||
profiles = {
|
||||
default = {
|
||||
fingerprint.DP1 = "XXX";
|
||||
config.DP1 = {
|
||||
scale = {
|
||||
x = 2;
|
||||
y = 4;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
config=home-files/.config/autorandr/default/config
|
||||
|
||||
assertFileExists $config
|
||||
assertFileContent $config \
|
||||
${
|
||||
pkgs.writeText "scale-expected.conf" ''
|
||||
output DP1
|
||||
scale 2x4''
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -19,10 +19,8 @@ with lib;
|
|||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.getmail/getmailhm@example.com
|
||||
assertFileContent home-files/.getmail/getmailhm@example.com ${
|
||||
./getmail-expected.conf
|
||||
}
|
||||
assertFileExists home-files/.getmail/getmailrc
|
||||
assertFileContent home-files/.getmail/getmailrc ${./getmail-expected.conf}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ with lib;
|
|||
programs.lieer.enable = true;
|
||||
|
||||
accounts.email.accounts."hm@example.com" = {
|
||||
flavor = "gmail.com";
|
||||
lieer.enable = true;
|
||||
notmuch.enable = true;
|
||||
};
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
["The programs.mpv \"package\" option is mutually exclusive with \"scripts\" option."]
|
|
@ -17,13 +17,9 @@
|
|||
})
|
||||
];
|
||||
|
||||
home.file.result.text = builtins.toJSON
|
||||
(map (a: a.message) (lib.filter (a: !a.assertion) config.assertions));
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/result \
|
||||
${./mpv-invalid-settings-expected.json}
|
||||
'';
|
||||
test.asserts.assertions.expected = [
|
||||
''
|
||||
The programs.mpv "package" option is mutually exclusive with "scripts" option.''
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ with lib;
|
|||
config = {
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
primary = true;
|
||||
msmtp.enable = true;
|
||||
neomutt = {
|
||||
enable = true;
|
||||
|
|
|
@ -8,7 +8,6 @@ with lib;
|
|||
config = {
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
primary = true;
|
||||
notmuch.enable = true;
|
||||
neomutt = {
|
||||
enable = true;
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
["Cannot use the rofi options 'theme' and 'colors' simultaneously.\n"]
|
|
@ -17,16 +17,11 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
home.file.result.text = builtins.toJSON
|
||||
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
|
||||
|
||||
nixpkgs.overlays =
|
||||
[ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/result \
|
||||
${./assert-on-both-theme-and-colors-expected.json}
|
||||
'';
|
||||
test.asserts.assertions.expected = [''
|
||||
Cannot use the rofi options 'theme' and 'colors' simultaneously.
|
||||
''];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,13 +17,6 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
home.file.result.text = builtins.toJSON
|
||||
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent home-files/result ${
|
||||
./forwards-paths-with-ports-error.json
|
||||
}
|
||||
'';
|
||||
test.asserts.assertions.expected = [ "Forwarded paths cannot have ports." ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,13 +21,6 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
home.file.result.text = builtins.toJSON
|
||||
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent home-files/result ${
|
||||
./forwards-paths-with-ports-error.json
|
||||
}
|
||||
'';
|
||||
test.asserts.assertions.expected = [ "Forwarded paths cannot have ports." ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,13 +21,6 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
home.file.result.text = builtins.toJSON
|
||||
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent home-files/result ${
|
||||
./forwards-paths-with-ports-error.json
|
||||
}
|
||||
'';
|
||||
test.asserts.assertions.expected = [ "Forwarded paths cannot have ports." ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
["Forwarded paths cannot have ports."]
|
|
@ -21,13 +21,6 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
home.file.result.text = builtins.toJSON
|
||||
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent home-files/result ${
|
||||
./forwards-paths-with-ports-error.json
|
||||
}
|
||||
'';
|
||||
test.asserts.assertions.expected = [ "Forwarded paths cannot have ports." ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,13 +21,6 @@ with lib;
|
|||
};
|
||||
};
|
||||
|
||||
home.file.result.text = builtins.toJSON
|
||||
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent home-files/result ${
|
||||
./forwards-paths-with-ports-error.json
|
||||
}
|
||||
'';
|
||||
test.asserts.assertions.expected = [ "Forwarded paths cannot have ports." ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,9 +9,14 @@ with lib;
|
|||
services.lieer.enable = true;
|
||||
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com".lieer.enable = true;
|
||||
"hm@example.com".lieer.sync.enable = true;
|
||||
"hm@example.com".notmuch.enable = true;
|
||||
"hm@example.com" = {
|
||||
flavor = "gmail.com";
|
||||
lieer = {
|
||||
enable = true;
|
||||
sync.enable = true;
|
||||
};
|
||||
notmuch.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
|
|
Loading…
Reference in a new issue