disko/tests/test.nix

39 lines
1 KiB
Nix
Raw Normal View History

{ makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
, pkgs ? (import <nixpkgs> {})
}:
let
makeTest' = args:
makeTest args {
inherit pkgs;
inherit (pkgs) system;
};
2022-08-24 14:46:36 +00:00
disko-config = import ../example/raid.nix;
tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. {}).create disko-config);
tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. {}).mount disko-config);
in makeTest' {
2018-08-05 09:45:15 +00:00
name = "disko";
nodes.machine =
{ config, pkgs, modulesPath, ... }:
2018-08-05 09:45:15 +00:00
{
imports = [
(modulesPath + "/profiles/installation-device.nix")
(modulesPath + "/profiles/base.nix")
2018-08-05 09:45:15 +00:00
];
# speed-up eval
documentation.enable = false;
2022-08-24 14:46:36 +00:00
virtualisation.emptyDiskImages = [ 512 512 ];
2018-08-05 09:45:15 +00:00
};
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
2022-08-24 14:46:36 +00:00
machine.succeed("test -b /dev/md/raid1");
'';
}