diff --git a/autopatch/autopatch.go b/autopatch/autopatch.go index 7c533b73..3935382a 100644 --- a/autopatch/autopatch.go +++ b/autopatch/autopatch.go @@ -11,7 +11,7 @@ package autopatch import ( "bytes" "encoding/json" - "fmt" + "errors" "io" "net/http" "net/http/httptest" @@ -329,7 +329,7 @@ func PatchResource(api huma.API, path *huma.PathItem) { var nullabilitySettings MergePatchNullabilitySettings if extension, ok := oapi.Extensions[MergePatchNullabilityExtension]; ok { if nullabilitySettings, ok = extension.(MergePatchNullabilitySettings); !ok { - huma.WriteErr(api, ctx, http.StatusInternalServerError, "Unable to parse nullability settings", fmt.Errorf("invalid nullability settings type")) + huma.WriteErr(api, ctx, http.StatusInternalServerError, "Unable to parse nullability settings", errors.New("invalid nullability settings type")) return } else if nullabilitySettings.Enabled { preserveNullsInMergePatch = true diff --git a/autopatch/autopatch_test.go b/autopatch/autopatch_test.go index 4c7bd794..2a58507c 100644 --- a/autopatch/autopatch_test.go +++ b/autopatch/autopatch_test.go @@ -10,6 +10,7 @@ import ( "testing/iotest" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/danielgtaylor/huma/v2" "github.com/danielgtaylor/huma/v2/humatest" @@ -520,7 +521,7 @@ func TestReplaceNulls(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { result, err := replaceNulls([]byte(tc.input), settings) - assert.NoError(t, err) + require.NoError(t, err) assert.JSONEq(t, tc.expected, string(result)) }) } @@ -566,7 +567,7 @@ func TestRestoreNulls(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { result, err := restoreNulls([]byte(tc.input), settings) - assert.NoError(t, err) + require.NoError(t, err) assert.JSONEq(t, tc.expected, string(result)) }) }