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
+4 -4
View File
@@ -137,6 +137,8 @@ func TestDaemonStartBridgeWithoutIPAssociation(t *testing.T) {
}
func TestDaemonIptablesClean(t *testing.T) {
defer deleteAllContainers()
d := NewDaemon(t)
if err := d.StartWithBusybox(); err != nil {
t.Fatalf("Could not start daemon with busybox: %v", err)
@@ -174,12 +176,12 @@ func TestDaemonIptablesClean(t *testing.T) {
t.Fatalf("iptables output should not have contained %q, but was %q", ipTablesSearchString, out)
}
deleteAllContainers()
logDone("daemon - run,iptables - iptables rules cleaned after daemon restart")
}
func TestDaemonIptablesCreate(t *testing.T) {
defer deleteAllContainers()
d := NewDaemon(t)
if err := d.StartWithBusybox(); err != nil {
t.Fatalf("Could not start daemon with busybox: %v", err)
@@ -226,8 +228,6 @@ func TestDaemonIptablesCreate(t *testing.T) {
t.Fatalf("iptables output after restart should have contained %q, but was %q", ipTablesSearchString, out)
}
deleteAllContainers()
logDone("daemon - run,iptables - iptables rules for always restarted container created after daemon restart")
}