fix(lint): resolve remaining nil dereference warnings

This commit is contained in:
wucm667
2026-08-11 16:57:39 +08:00
parent 1afb8264e5
commit 5ea03c178d
3 changed files with 6 additions and 9 deletions
@@ -36,9 +36,7 @@ func TestExtractImagesUpstreamError_IncompleteIsRetryable(t *testing.T) {
func TestExtractImagesUpstreamError_IncompleteContentFilterNotRetryable(t *testing.T) {
body := "data: {\"type\":\"response.incomplete\",\"response\":{\"id\":\"r\",\"status\":\"incomplete\",\"incomplete_details\":{\"reason\":\"content_filter\"}}}\n\n"
got := extractOpenAIImagesUpstreamError([]byte(body))
if got == nil {
t.Fatal("content_filter incomplete should produce error")
}
require.NotNil(t, got)
if got.StatusCode != http.StatusBadRequest {
t.Fatalf("content_filter should be 400 (non-retryable), got %d", got.StatusCode)
}
@@ -6,6 +6,7 @@ import (
"testing"
infraerrors "github.com/Wei-Shaw/sub2api/internal/pkg/errors"
"github.com/stretchr/testify/require"
)
type stubOpsRepoForUserErr struct {
@@ -119,9 +120,7 @@ func TestGetUserErrorRequestDetail_OwnershipEnforced(t *testing.T) {
if err2 != nil {
t.Fatalf("expected no error for legitimate access, got %v", err2)
}
if got2 == nil {
t.Fatal("expected non-nil detail for legitimate access")
}
require.NotNil(t, got2)
if got2.ID != 42 {
t.Errorf("want ID=42, got %d", got2.ID)
}
@@ -5,6 +5,8 @@ import (
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestMapUserErrorCategory(t *testing.T) {
@@ -132,9 +134,7 @@ func TestToUserErrorRequestDetail_WhitelistAndRedacts(t *testing.T) {
}
out := ToUserErrorRequestDetail(src)
if out == nil {
t.Fatal("expected non-nil detail")
}
require.NotNil(t, out)
// 基础字段正确映射
if out.ID != 999 {