chore: remove custom contains helpers, drop unnecessary comment
This commit is contained in:
parent
5d90a3f1be
commit
6ed1590578
4 changed files with 4 additions and 29 deletions
1
.tool-versions
Normal file
1
.tool-versions
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
golang 1.26.4
|
||||||
|
|
@ -35,7 +35,7 @@ func TestChannelMsgSerialization(t *testing.T) {
|
||||||
s := string(data)
|
s := string(data)
|
||||||
checks := []string{"agent:123", "phx_join", "token", "test"}
|
checks := []string{"agent:123", "phx_join", "token", "test"}
|
||||||
for _, c := range checks {
|
for _, c := range checks {
|
||||||
if !contains(s, c) {
|
if !strings.Contains(s, c) {
|
||||||
t.Errorf("expected %q in JSON output %q", c, s)
|
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 {
|
func testPools(t *testing.T) *jobPools {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
p := &jobPools{
|
p := &jobPools{
|
||||||
|
|
|
||||||
|
|
@ -660,24 +660,11 @@ func TestReadWordExceedsMaxSize(t *testing.T) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("expected error for word exceeding max size")
|
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)
|
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) {
|
func TestReadSentenceError(t *testing.T) {
|
||||||
// Buffer with valid length byte but truncated word data
|
// Buffer with valid length byte but truncated word data
|
||||||
buf := bytes.NewBuffer([]byte{0x03, 'a'}) // length=3 but only 1 byte of data
|
buf := bytes.NewBuffer([]byte{0x03, 'a'}) // length=3 but only 1 byte of data
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ func selfUpdate(downloadURL, expectedChecksum string) error {
|
||||||
return fmt.Errorf("create temp: %w", err)
|
return fmt.Errorf("create temp: %w", err)
|
||||||
}
|
}
|
||||||
tempPath := tempFile.Name()
|
tempPath := tempFile.Name()
|
||||||
defer func() { _ = os.Remove(tempPath) }() // cleanup on any failure
|
defer func() { _ = os.Remove(tempPath) }()
|
||||||
|
|
||||||
if _, err := tempFile.Write(body); err != nil {
|
if _, err := tempFile.Write(body); err != nil {
|
||||||
_ = tempFile.Close()
|
_ = tempFile.Close()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue