Skip to content

Commit

Permalink
Updated client_test to solve lint error (#900)
Browse files Browse the repository at this point in the history
* updated client_test to solve lint error

* modified golangci yml to solve linter issues

* minor change
  • Loading branch information
AyushSawant18588 authored Nov 19, 2024
1 parent 6d066bb commit b3ece4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ linters-settings:
# Default: true
skipRecvDeref: false

gomnd:
mnd:
# List of function patterns to exclude from analysis.
# Values always ignored: `time.Date`
# Default: []
Expand Down Expand Up @@ -167,7 +167,7 @@ linters:
- durationcheck # check for two durations multiplied together
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
# Removed execinquery (deprecated). execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
- exhaustive # check exhaustiveness of enum switch statements
- exportloopref # checks for pointers to enclosing loop variables
- forbidigo # Forbids identifiers
Expand All @@ -180,14 +180,14 @@ linters:
- gocyclo # Computes and checks the cyclomatic complexity of functions
- godot # Check if comments end in a period
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
- gomnd # An analyzer to detect magic numbers.
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
- goprintffuncname # Checks that printf-like functions are named with f at the end
- gosec # Inspects source code for security problems
- lll # Reports long lines
- makezero # Finds slice declarations with non-zero initial length
# - nakedret # Finds naked returns in functions greater than a specified function length
- mnd # An analyzer to detect magic numbers.
- nestif # Reports deeply nested if statements
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
Expand Down
10 changes: 8 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,14 @@ func TestClient_suffixWithAPIVersion(t *testing.T) {
}
defer func() {
if r := recover(); r != nil {
if r.(string) != tt.wantPanic {
t.Errorf("suffixWithAPIVersion() = %v, want %v", r, tt.wantPanic)
// Check if the panic message matches the expected panic message
if rStr, ok := r.(string); ok {
if rStr != tt.wantPanic {
t.Errorf("suffixWithAPIVersion() = %v, want %v", rStr, tt.wantPanic)
}
} else {
// If the panic is not a string, log it
t.Errorf("suffixWithAPIVersion() panicked with non-string value: %v", r)
}
}
}()
Expand Down

0 comments on commit b3ece4d

Please sign in to comment.