mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-09 16:18:55 +00:00
fix: resolve 8 staticcheck lint errors in test files
SA1029: use typed context key instead of string in main_test.go S1039: remove unnecessary fmt.Sprintf in validation_test.go SA4023: fix unreachable nil check on concrete error type SA4006: fix unused variable assignments in stepca_test.go (4 occurrences) SA4000: fix duplicate expression in ssh_test.go (BEGIN vs END CERTIFICATE) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -522,7 +521,7 @@ func TestValidationError_ErrorMessage(t *testing.T) {
|
||||
name: "error with field info",
|
||||
err: ValidationError{
|
||||
Field: "test_field",
|
||||
Message: fmt.Sprintf("test_field must be 10 characters or fewer"),
|
||||
Message: "test_field must be 10 characters or fewer",
|
||||
},
|
||||
wantMsg: "test_field must be 10 characters or fewer",
|
||||
},
|
||||
@@ -540,16 +539,16 @@ func TestValidationError_ErrorMessage(t *testing.T) {
|
||||
|
||||
// TestValidationError_IsError tests that ValidationError satisfies error interface.
|
||||
func TestValidationError_IsError(t *testing.T) {
|
||||
var err error = ValidationError{
|
||||
ve := ValidationError{
|
||||
Field: "test",
|
||||
Message: "test error",
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
t.Error("ValidationError should satisfy error interface")
|
||||
}
|
||||
// Assign to interface variable to verify it satisfies error
|
||||
var err error = ve
|
||||
_ = err
|
||||
|
||||
msg := err.Error()
|
||||
msg := ve.Error()
|
||||
if msg != "test error" {
|
||||
t.Errorf("Expected error message 'test error', got %q", msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user