mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 05:31:47 +00:00
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:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user