Better test cleanup with defer

This fixes a few misuses of `deleteAllContainers()` cleanup
method in integration-cli suite by moving call to the
beginning of the method and guaranteeing their execution
(including panics) with `defer`s.

Also added some forgotten cleanup calls while I'm at it.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
This commit is contained in:
Ahmet Alp Balkan
2015-02-20 14:04:36 -08:00
parent a78ce5c228
commit 70407ce40c
16 changed files with 290 additions and 251 deletions
+1 -1
View File
@@ -10,6 +10,7 @@ import (
func TestNetworkNat(t *testing.T) {
testRequires(t, SameHostDaemon)
defer deleteAllContainers()
iface, err := net.InterfaceByName("eth0")
if err != nil {
@@ -56,7 +57,6 @@ func TestNetworkNat(t *testing.T) {
if out, _, err = runCommandWithOutput(killCmd); err != nil {
t.Fatalf("failed to kill container: %s, %v", out, err)
}
deleteAllContainers()
logDone("network - make sure nat works through the host")
}