about summary refs log tree commit diff
path: root/tests/make-test.nix
blob: c20bd3ef6bf096247f2411e2e5632595993667a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
f: { system ? builtins.currentSystem, ... } @ args: let
  testLib = import <nixpkgs/nixos/lib/testing.nix> {
    inherit system;
  };

  pkgs = import <nixpkgs> { inherit system; };

  testArgs = if builtins.isFunction f then f (args // {
    pkgs = pkgs // {
      labernix = import ../pkgs { inherit pkgs; };
    };
  }) else f;

  nodes = if testArgs ? machine then {
    inherit (testArgs) machine;
  } else testArgs.nodes;

  injectCommon = name: values: {
    imports = [ ../common.nix values ];
  };

  testArgsWithCommon = removeAttrs testArgs [ "machine" ] // {
    nodes = testLib.mapAttrs injectCommon nodes;
  };

in testLib.makeTest testArgs