diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2020-02-10 02:21:24 +0100 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2020-02-11 14:42:30 +0100 |
commit | 93943acbc5d795a34a0f933d3b31094fc2c7b78f (patch) | |
tree | 8a4ab4853e3f38682431b78ad0b17b53620d147c /nixos/tests/containers-imperative.nix | |
parent | c6fa3c201c1ef175ea58f5c0919b39a48a83bb3c (diff) | |
download | nixpkgs-93943acbc5d795a34a0f933d3b31094fc2c7b78f.tar nixpkgs-93943acbc5d795a34a0f933d3b31094fc2c7b78f.tar.gz nixpkgs-93943acbc5d795a34a0f933d3b31094fc2c7b78f.tar.bz2 nixpkgs-93943acbc5d795a34a0f933d3b31094fc2c7b78f.tar.lz nixpkgs-93943acbc5d795a34a0f933d3b31094fc2c7b78f.tar.xz nixpkgs-93943acbc5d795a34a0f933d3b31094fc2c7b78f.tar.zst nixpkgs-93943acbc5d795a34a0f933d3b31094fc2c7b78f.zip |
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.nix | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/nixos/tests/containers-imperative.nix b/nixos/tests/containers-imperative.nix index 61df74042cb..c4f2002918f 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") ''; }) |