chore: remove custom contains helpers, drop unnecessary comment

This commit is contained in:
Graham McIntire 2026-06-06 14:42:26 -05:00
parent 5d90a3f1be
commit 6ed1590578
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
4 changed files with 4 additions and 29 deletions

1
.tool-versions Normal file
View file

@ -0,0 +1 @@
golang 1.26.4

View file

@ -35,7 +35,7 @@ func TestChannelMsgSerialization(t *testing.T) {
s := string(data)
checks := []string{"agent:123", "phx_join", "token", "test"}
for _, c := range checks {
if !contains(s, c) {
if !strings.Contains(s, c) {
t.Errorf("expected %q in JSON output %q", c, s)
}
}
@ -69,19 +69,6 @@ func TestChannelMsgNullRef(t *testing.T) {
}
}
func contains(s, substr string) bool {
return len(s) >= len(substr) && searchString(s, substr)
}
func searchString(s, substr string) bool {
for i := 0; i <= len(s)-len(substr); i++ {
if s[i:i+len(substr)] == substr {
return true
}
}
return false
}
func testPools(t *testing.T) *jobPools {
t.Helper()
p := &jobPools{

View file

@ -660,24 +660,11 @@ func TestReadWordExceedsMaxSize(t *testing.T) {
if err == nil {
t.Error("expected error for word exceeding max size")
}
if !containsStr(err.Error(), "exceeds max") {
if !strings.Contains(err.Error(), "exceeds max") {
t.Errorf("expected 'exceeds max' in error, got: %v", err)
}
}
func containsStr(s, sub string) bool {
return len(s) >= len(sub) && searchStr(s, sub)
}
func searchStr(s, sub string) bool {
for i := 0; i <= len(s)-len(sub); i++ {
if s[i:i+len(sub)] == sub {
return true
}
}
return false
}
func TestReadSentenceError(t *testing.T) {
// Buffer with valid length byte but truncated word data
buf := bytes.NewBuffer([]byte{0x03, 'a'}) // length=3 but only 1 byte of data

View file

@ -85,7 +85,7 @@ func selfUpdate(downloadURL, expectedChecksum string) error {
return fmt.Errorf("create temp: %w", err)
}
tempPath := tempFile.Name()
defer func() { _ = os.Remove(tempPath) }() // cleanup on any failure
defer func() { _ = os.Remove(tempPath) }()
if _, err := tempFile.Write(body); err != nil {
_ = tempFile.Close()