diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2022-08-26 14:59:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 14:59:28 +0100 |
commit | adf901d58155ca268d15351fff164d3ef38a0890 (patch) | |
tree | c6057a3d362e06742073b35d4c11db7ee9a0a820 /tests/lib.nix | |
parent | 6b0b20da18cdffd09f04faee7128c557bcb9f054 (diff) | |
parent | 9bb4aec9640cbc30e241c267158e506278862b5e (diff) |
Merge pull request #27 from nix-community/zfs
zfs, lvm raid, btrfs subvolumes support & some fixups
Diffstat (limited to 'tests/lib.nix')
-rw-r--r-- | tests/lib.nix | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/lib.nix b/tests/lib.nix new file mode 100644 index 0000000..2ec42e6 --- /dev/null +++ b/tests/lib.nix @@ -0,0 +1,48 @@ +{ pkgs ? (import <nixpkgs> { }) +, makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix> +, ... +}: +{ + makeDiskoTest = + { disko-config + , extraTestScript + , extraConfig ? { } + }: + let + lib = pkgs.lib; + makeTest' = args: + makeTest args { + inherit pkgs; + inherit (pkgs) system; + }; + tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config); + tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config); + num-disks = builtins.length (builtins.filter (x: builtins.match "vd." x == [ ]) (lib.attrNames disko-config.content)); + in + makeTest' { + name = "disko"; + + nodes.machine = + { config, pkgs, modulesPath, ... }: + + { + imports = [ + (modulesPath + "/profiles/installation-device.nix") + (modulesPath + "/profiles/base.nix") + ]; + + # speed-up eval + documentation.enable = false; + + virtualisation.emptyDiskImages = builtins.genList (_: 512) num-disks; + } // extraConfig; + + testScript = '' + machine.succeed("echo 'secret' > /tmp/secret.key"); + machine.succeed("${tsp-create}"); + machine.succeed("${tsp-mount}"); + machine.succeed("${tsp-mount}"); # verify that the command is idempotent + ${extraTestScript} + ''; + }; +} |