From 600be995fb7032f676f24b39bcd31da18c7a64a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Sep 2025 14:35:30 +0000 Subject: [PATCH] Fix golangci-lint issue: replace custom contains function with strings.Contains Co-authored-by: zhaque44 <20215376+zhaque44@users.noreply.github.com> --- pkg/state/diff_error_propagation_test.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/state/diff_error_propagation_test.go b/pkg/state/diff_error_propagation_test.go index a40d85d5..4c288bab 100644 --- a/pkg/state/diff_error_propagation_test.go +++ b/pkg/state/diff_error_propagation_test.go @@ -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)) -} \ No newline at end of file