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