mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-18 16:46:17 +00:00
Mirrors the .md/.txt sweep across all tracked _test.go, testdata XML,
and .http integration files. Test files are self-contained (producer
+ assertion in the same file), so the matched-pair swap stays green
under `go test ./...`.
Mapping applied:
192.168.178.[0-9]+ → 192.0.2.[same]
192.168.1.[0-9]+ → 192.0.2.[same]
Sound Machinechen → Living Room SoundTouch
A Sound Machine → Kitchen SoundTouch
A81B6A536A98 + case/separator variants → AABBCCDDEEFF (etc.)
A81B6A849D99 → AABBCCDDEE01
A81B6A849D88 → AABBCCDDEE03
A81B6A536A09 → AABBCCDDEE04
884AEAEEBD27 → AABBCCDDEE02
3230304 → 1000001
9569497 → 1000002
Two semantic fixes alongside the bulk swap:
- pkg/service/zeroconf/zeroconf_test.go: the "private 192" and
"strips query" cases pin acceptance of RFC-1918 192.168/16. They
must use a real 192.168 value; doc-range IPs would (correctly) be
rejected by validateZcBaseURL. Switched to 192.168.10.10 — generic
enough not to match any home LAN default, real enough for the
validator. Added a comment explaining why this single test still
carries a 192.168 literal.
- pkg/service/setup/setup_test.go: TestTestDNSRedirection mocks the
device's `od -An -tu1` byte output, which is space-separated
octets ("192 168 1 100"). My sed only matched the dot-separated
form, so the mock was returning the old IP while the test
assertions had moved to the doc range. Updated to " 192 0 2 100".
go build ./... clean. go test ./... clean (only TestDocsConsistency
remains failing, which is a pre-existing/untracked-file issue).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package proxy
|
|
|
|
import (
|
|
"regexp"
|
|
"testing"
|
|
)
|
|
|
|
func TestDefaultPatterns(t *testing.T) {
|
|
patterns := DefaultPatterns()
|
|
if len(patterns) != 4 {
|
|
t.Errorf("Expected 4 default patterns, got %d", len(patterns))
|
|
}
|
|
|
|
expectedNames := []string{"IPv4", "UUID", "AccountID", "DeviceID"}
|
|
for i, name := range expectedNames {
|
|
if patterns[i].Name != name {
|
|
t.Errorf("Expected pattern %d name %s, got %s", i, name, patterns[i].Name)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPathPatterns_Sanitize(t *testing.T) {
|
|
patterns := DefaultPatterns()
|
|
// Need to compile them as DefaultPatterns() in its new form doesn't compile them (main.go or LoadPatterns does it)
|
|
// Wait, actually the new DefaultPatterns() I wrote doesn't compile them.
|
|
// But PathPatterns.Sanitize checks for compiled != nil.
|
|
|
|
// Let's manually compile for the test
|
|
for i := range patterns {
|
|
patterns[i].compiled = mustCompile(patterns[i].Regexp)
|
|
}
|
|
|
|
tests := []struct {
|
|
segment string
|
|
wantRepl string
|
|
}{
|
|
{"192.0.2.100", "{ip}"},
|
|
{"1234567", "{accountId}"},
|
|
{"12345", "{accountId}"},
|
|
{"12345678-1234-5678-9012-123456789012", "{uuid}"},
|
|
{"D05FB8A848E5", "{device_id}"},
|
|
{"some-other-segment", ""},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
repl, _ := patterns.Sanitize(tt.segment)
|
|
if tt.wantRepl == "" {
|
|
if repl != tt.segment {
|
|
t.Errorf("Sanitize(%q) = %q, want %q (no change)", tt.segment, repl, tt.segment)
|
|
}
|
|
} else {
|
|
if repl != tt.wantRepl {
|
|
t.Errorf("Sanitize(%q) = %q, want %q", tt.segment, repl, tt.wantRepl)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func mustCompile(re string) *regexp.Regexp {
|
|
return regexp.MustCompile(re)
|
|
}
|