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:
parent
e452050dc0
commit
600be995fb
|
|
@ -2,6 +2,7 @@ package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -48,7 +49,7 @@ func TestIsReleaseInstalled_HandlesConnectionError(t *testing.T) {
|
||||||
|
|
||||||
// Check if the error contains the expected message
|
// Check if the error contains the expected message
|
||||||
expectedMsg := "Kubernetes cluster unreachable"
|
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())
|
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) {
|
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")
|
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))
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue