mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	test: skip certain network-specific tests on non-Linux (#7318)
Add conditional test skipping for bind and readme tests that rely on Linux-specific loopback interface behavior. These tests reference network configurations that may not exist on for e.g. macOS or other platforms, causing spurious test failures. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| package bind | ||||
|  | ||||
| import ( | ||||
| 	"runtime" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/coredns/caddy" | ||||
| @@ -8,6 +9,12 @@ import ( | ||||
| ) | ||||
|  | ||||
| func TestSetup(t *testing.T) { | ||||
| 	// Skip on non-Linux systems as some tests refer to for e.g. loopback interfaces which | ||||
| 	// are not present on all systems. | ||||
| 	if runtime.GOOS != "linux" { | ||||
| 		t.Skipf("Skipping bind test on %s", runtime.GOOS) | ||||
| 	} | ||||
|  | ||||
| 	for i, test := range []struct { | ||||
| 		config   string | ||||
| 		expected []string | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"runtime" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"testing" | ||||
| @@ -45,6 +46,12 @@ PrivateKey: f03VplaIEA+KHI9uizlemUSbUJH86hPBPjmcUninPoM= | ||||
| // While we're at it - we also check the README.md itself. It should at least have the sections: | ||||
| // Name, Description, Syntax and Examples. See plugin.md for more details. | ||||
| func TestReadme(t *testing.T) { | ||||
| 	// Skip on non-Linux systems as some tests refer to for e.g. loopback interfaces which | ||||
| 	// are not present on all systems. | ||||
| 	if runtime.GOOS != "linux" { | ||||
| 		t.Skipf("Skipping readme test on %s", runtime.GOOS) | ||||
| 	} | ||||
|  | ||||
| 	port := 30053 | ||||
| 	caddy.Quiet = true | ||||
| 	dnsserver.Quiet = true | ||||
|   | ||||
		Reference in New Issue
	
	Block a user