about summary refs log tree commit diff
path: root/tests/make-test.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-03-17 23:44:29 +0100
committeraszlig <aszlig@redmoonstudios.org>2015-03-17 23:44:29 +0100
commit2ecebd2481790a912db98b00432514ad3f3ea083 (patch)
treea42862a07093dd62324ee533183439bf86ca3ac2 /tests/make-test.nix
parente5e5cfbf33008ca3260cd4f2dd78986694dfb027 (diff)
tests: Add make-test.nix with labernix packages.
We're going not only to modify all VM test nodes, but also inject the
updated pkgs into the tests own arguments, so we can refer to them even
outside of testing machine configuration modules.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'tests/make-test.nix')
-rw-r--r--tests/make-test.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/make-test.nix b/tests/make-test.nix
new file mode 100644
index 00000000..c20bd3ef
--- /dev/null
+++ b/tests/make-test.nix
@@ -0,0 +1,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