summaryrefslogtreecommitdiffstats
path: root/nixos/tests/containers-imperative.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2020-02-10 02:21:24 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2020-02-11 14:42:30 +0100
commit93943acbc5d795a34a0f933d3b31094fc2c7b78f (patch)
tree8a4ab4853e3f38682431b78ad0b17b53620d147c /nixos/tests/containers-imperative.nix
parentc6fa3c201c1ef175ea58f5c0919b39a48a83bb3c (diff)
nixos/nixos-container: ensure that the state-dir is cleaned up if a build fails
Diffstat (limited to 'nixos/tests/containers-imperative.nix')
-rw-r--r--nixos/tests/containers-imperative.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/nixos/tests/containers-imperative.nix b/nixos/tests/containers-imperative.nix
index 61df74042cb3..c4f2002918fc 100644
--- a/nixos/tests/containers-imperative.nix
+++ b/nixos/tests/containers-imperative.nix
@@ -46,6 +46,15 @@ import ./make-test-python.nix ({ pkgs, ...} : {
};
}
'';
+ brokenCfg = pkgs.writeText "broken.nix" ''
+ {
+ assertions = [
+ { assertion = false;
+ message = "I never evaluate";
+ }
+ ];
+ }
+ '';
in ''
with subtest("Make sure we have a NixOS tree (required by ‘nixos-container create’)"):
machine.succeed("PAGER=cat nix-env -qa -A nixos.hello >&2")
@@ -130,5 +139,11 @@ import ./make-test-python.nix ({ pkgs, ...} : {
with subtest("Ensure that the container path is gone"):
print(machine.succeed("ls -lsa /var/lib/containers"))
machine.succeed(f"test ! -e /var/lib/containers/{id1}")
+
+ with subtest("Ensure that a failed container creation doesn'leave any state"):
+ machine.fail(
+ "nixos-container create b0rk --config-file ${brokenCfg}"
+ )
+ machine.succeed(f"test ! -e /var/lib/containers/b0rk")
'';
})