Skip to content

Commit 8427a9a

Browse files
Copilotneongreen
andcommitted
Simplify test by using strings.Contains instead of custom helpers
Co-authored-by: neongreen <[email protected]>
1 parent d8d8387 commit 8427a9a

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

conf/pkg/folders/drift_test.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package folders
33
import (
44
"os"
55
"path/filepath"
6+
"strings"
67
"testing"
78
)
89

@@ -358,24 +359,10 @@ func TestFormatDriftSummary(t *testing.T) {
358359
t.Run(tt.name, func(t *testing.T) {
359360
result := FormatDriftSummary(tt.drifts)
360361
for _, substr := range tt.contains {
361-
if !containsString(result, substr) {
362+
if !strings.Contains(result, substr) {
362363
t.Errorf("FormatDriftSummary(%v) = %q, want to contain %q", tt.drifts, result, substr)
363364
}
364365
}
365366
})
366367
}
367368
}
368-
369-
func containsString(s, substr string) bool {
370-
return len(s) >= len(substr) && (s == substr || len(substr) == 0 ||
371-
(len(s) > 0 && len(substr) > 0 && findSubstring(s, substr)))
372-
}
373-
374-
func findSubstring(s, substr string) bool {
375-
for i := 0; i <= len(s)-len(substr); i++ {
376-
if s[i:i+len(substr)] == substr {
377-
return true
378-
}
379-
}
380-
return false
381-
}

0 commit comments

Comments
 (0)