test(model): покрытие SRV, неполных MX/SRV значений и изоляция теста приоритета MX
This commit is contained in:
@@ -37,6 +37,58 @@ func TestEqualMXPriorityAndOrder(t *testing.T) {
|
|||||||
if a.Equal(c) {
|
if a.Equal(c) {
|
||||||
t.Fatal("different priority must not be equal")
|
t.Fatal("different priority must not be equal")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Isolated case: same value count and same target, only priority differs —
|
||||||
|
// must fail on priority comparison, not on a length mismatch shortcut.
|
||||||
|
d := Record{Type: MX, Name: "example.com.", TTL: 3600, Values: []string{"10 mx1.example.com."}}
|
||||||
|
e := Record{Type: MX, Name: "example.com.", TTL: 3600, Values: []string{"20 mx1.example.com."}}
|
||||||
|
if d.Equal(e) {
|
||||||
|
t.Fatal("different MX priority with same target and value count must not be equal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEqualSRVBasic(t *testing.T) {
|
||||||
|
a := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 3600, Values: []string{
|
||||||
|
"10 20 5060 sipserver.example.com.",
|
||||||
|
"5 10 5061 backup.example.com.",
|
||||||
|
}}
|
||||||
|
b := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 3600, Values: []string{
|
||||||
|
"5 10 5061 BACKUP.Example.COM.",
|
||||||
|
"10 20 5060 SIPServer.Example.com.",
|
||||||
|
}}
|
||||||
|
if !a.Equal(b) {
|
||||||
|
t.Fatal("SRV records equal regardless of order and target case")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Isolated: identical single value except priority differs.
|
||||||
|
c1 := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 3600, Values: []string{"10 20 5060 sipserver.example.com."}}
|
||||||
|
c2 := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 3600, Values: []string{"20 20 5060 sipserver.example.com."}}
|
||||||
|
if c1.Equal(c2) {
|
||||||
|
t.Fatal("different SRV priority must not be equal")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Isolated: identical single value except port differs.
|
||||||
|
d1 := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 3600, Values: []string{"10 20 5060 sipserver.example.com."}}
|
||||||
|
d2 := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 3600, Values: []string{"10 20 5061 sipserver.example.com."}}
|
||||||
|
if d1.Equal(d2) {
|
||||||
|
t.Fatal("different SRV port must not be equal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNormalizeValueIncompleteNoPanic(t *testing.T) {
|
||||||
|
// MX value missing the target field.
|
||||||
|
a := Record{Type: MX, Name: "example.com.", TTL: 300, Values: []string{"10"}}
|
||||||
|
b := Record{Type: MX, Name: "example.com.", TTL: 300, Values: []string{"10"}}
|
||||||
|
if !a.Equal(b) {
|
||||||
|
t.Fatal("incomplete MX values with identical content should be equal, not panic")
|
||||||
|
}
|
||||||
|
|
||||||
|
// SRV value missing port and target fields.
|
||||||
|
c := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 300, Values: []string{"10 20"}}
|
||||||
|
d := Record{Type: SRV, Name: "_sip._tcp.example.com.", TTL: 300, Values: []string{"10 20"}}
|
||||||
|
if !c.Equal(d) {
|
||||||
|
t.Fatal("incomplete SRV values with identical content should be equal, not panic")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEqualTXTCaseSensitive(t *testing.T) {
|
func TestEqualTXTCaseSensitive(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user