Fix golangci-lint issue: replace custom contains function with strings.Contains

Co-authored-by: zhaque44 <20215376+zhaque44@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-09-02 14:35:30 +00:00
parent e452050dc0
commit 600be995fb
1 changed files with 4 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package state
import (
"errors"
"strings"
"sync"
"testing"
@ -13,12 +14,12 @@ import (
func TestIsReleaseInstalled_HandlesConnectionError(t *testing.T) {
logger := zap.NewNop().Sugar()
state := &HelmState{
logger: logger,
}
// Create a custom helm mock that fails on List operations
// Create a custom helm mock that fails on List operations
helm := &CustomFailingHelm{
Helm: &exectest.Helm{
DiffMutex: &sync.Mutex{},
@ -48,7 +49,7 @@ func TestIsReleaseInstalled_HandlesConnectionError(t *testing.T) {
// Check if the error contains the expected message
expectedMsg := "Kubernetes cluster unreachable"
if err.Error() != expectedMsg && !contains(err.Error(), "Kubernetes cluster unreachable") {
if err.Error() != expectedMsg && !strings.Contains(err.Error(), "Kubernetes cluster unreachable") {
t.Fatalf("expected error to contain 'Kubernetes cluster unreachable', but got: %v", err.Error())
}
}
@ -61,7 +62,3 @@ type CustomFailingHelm struct {
func (h *CustomFailingHelm) List(context helmexec.HelmContext, filter string, flags ...string) (string, error) {
return "", errors.New("Kubernetes cluster unreachable: Get \"http://localhost:8080/version\": dial tcp [::1]:8080: connect: connection refused")
}
func contains(s, substr string) bool {
return len(s) >= len(substr) && s[:len(substr)] == substr || (len(s) > len(substr) && contains(s[1:], substr))
}