Pārlūkot izejas kodu

Test that iptables() looks for iptables in the PATH

Solomon Hykes 12 gadi atpakaļ
vecāks
revīzija
ba33d67a1a
1 mainītis faili ar 13 papildinājumiem un 0 dzēšanām
  1. 13 0
      network_test.go

+ 13 - 0
network_test.go

@@ -2,9 +2,22 @@ package docker
 
 import (
 	"net"
+	"os"
 	"testing"
 )
 
+func TestIptables(t *testing.T) {
+	if err := iptables("-L"); err != nil {
+		t.Fatal(err)
+	}
+	path := os.Getenv("PATH")
+	os.Setenv("PATH", "")
+	defer os.Setenv("PATH", path)
+	if err := iptables("-L"); err == nil {
+		t.Fatal("Not finding iptables in the PATH should cause an error")
+	}
+}
+
 func TestNetworkRange(t *testing.T) {
 	// Simple class C test
 	_, network, _ := net.ParseCIDR("192.168.0.1/24")