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:
Ville Vesilehto
2025-05-23 19:23:14 +03:00
committed by GitHub
parent a070d22bc3
commit 1948b6efc3
2 changed files with 14 additions and 0 deletions

View File

@@ -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

View File

@@ -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