fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Thiago Kenji Okadatests: fix test.assert.assertions.enable not workingb78b5843

master
1.7 KiB81 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5{
6  options.test.asserts = {
7    warnings = {
8      enable = mkOption {
9        type = types.bool;
10        default = true;
11        description = "Whether warning asserts are enabled.";
12      };
13
14      expected = mkOption {
15        type = types.listOf types.str;
16        default = [ ];
17        description = ''
18          List of expected warnings.
19        '';
20      };
21    };
22
23    assertions = {
24      enable = mkOption {
25        type = types.bool;
26        default = true;
27        description = "Whether assertion asserts are enabled.";
28      };
29
30      expected = mkOption {
31        type = types.listOf types.str;
32        default = [ ];
33        description = ''
34          List of expected assertions.
35        '';
36      };
37    };
38  };
39
40  config = mkMerge [
41    (mkIf config.test.asserts.warnings.enable {
42      home.file = {
43        "asserts/warnings.actual".text = concatStringsSep ''
44
45          --
46        '' config.warnings;
47      };
48
49      nmt.script = ''
50        assertFileContent \
51          home-files/asserts/warnings.actual \
52          ${
53            pkgs.writeText "warnings.expected" (concatStringsSep ''
54
55              --
56            '' config.test.asserts.warnings.expected)
57          }
58      '';
59    })
60
61    (mkIf config.test.asserts.assertions.enable {
62      home.file = {
63        "asserts/assertions.actual".text = concatStringsSep ''
64
65          --
66        '' (map (x: x.message) (filter (x: !x.assertion) config.assertions));
67      };
68
69      nmt.script = ''
70        assertFileContent \
71          home-files/asserts/assertions.actual \
72          ${
73            pkgs.writeText "assertions.expected" (concatStringsSep ''
74
75              --
76            '' config.test.asserts.assertions.expected)
77          }
78      '';
79    })
80  ];
81}