Files
zhangthree78 daa5d69261 fix(dns): make marked-client Control assertions platform-specific
Review (goal verification) found that socket_test.go asserted
Dialer.Control != nil without build tags, so 'go test ./core/dns/'
fails on Windows where markedDialer() deliberately omits Control
(SO_MARK is a Linux-only option; markFd is a no-op there).

Move the Control assertions to socket_unix_test.go (//go:build !windows);
socket_test.go keeps the platform-neutral assertions (Net/UDPSize/timeouts/
Dialer non-nil). Verified: Linux go build + go test all pass, and
GOOS=windows go vet compiles the test files cleanly.
2026-08-17 01:01:15 +08:00

39 lines
880 B
Go

package dns
import (
"testing"
"time"
)
func TestNewMarkedDnsClient(t *testing.T) {
client := newMarkedDnsClient("udp")
if client.Net != "udp" {
t.Errorf("Net = %q, want %q", client.Net, "udp")
}
if client.UDPSize != 4096 {
t.Errorf("UDPSize = %d, want 4096", client.UDPSize)
}
if client.Timeout != 5*time.Second {
t.Errorf("Timeout = %v, want 5s", client.Timeout)
}
if client.ReadTimeout != 5*time.Second {
t.Errorf("ReadTimeout = %v, want 5s", client.ReadTimeout)
}
if client.WriteTimeout != 5*time.Second {
t.Errorf("WriteTimeout = %v, want 5s", client.WriteTimeout)
}
if client.Dialer == nil {
t.Fatal("Dialer is nil")
}
}
func TestNewMarkedDnsClientTCP(t *testing.T) {
client := newMarkedDnsClient("tcp")
if client.Net != "tcp" {
t.Errorf("Net = %q, want %q", client.Net, "tcp")
}
if client.Dialer == nil {
t.Fatal("Dialer is nil")
}
}