fix linter issues

This commit is contained in:
jmorganca 2024-08-25 12:41:37 -07:00
parent 9899f18e18
commit dc04f41eb7
2 changed files with 5 additions and 4 deletions

View File

@ -584,7 +584,7 @@ func (w *BaseWriter) writeError(code int, data []byte) (int, error) {
} }
w.ResponseWriter.Header().Set("Content-Type", "application/json") w.ResponseWriter.Header().Set("Content-Type", "application/json")
err = json.NewEncoder(w.ResponseWriter).Encode(NewError(http.StatusInternalServerError, serr.Error())) err = json.NewEncoder(w.ResponseWriter).Encode(NewError(code, serr.Error()))
if err != nil { if err != nil {
return 0, err return 0, err
} }

View File

@ -20,7 +20,7 @@ import (
func capture(req any) gin.HandlerFunc { func capture(req any) gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
body, _ := io.ReadAll(c.Request.Body) body, _ := io.ReadAll(c.Request.Body)
json.Unmarshal(body, req) _ = json.Unmarshal(body, req)
c.Next() c.Next()
} }
} }
@ -200,7 +200,7 @@ func TestChatMiddleware(t *testing.T) {
}) })
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
r, _ := http.NewRequest("POST", "/api/chat", strings.NewReader(tt.body)) r, _ := http.NewRequest(http.MethodPost, "/api/chat", strings.NewReader(tt.body))
r.Header.Set("Content-Type", "application/json") r.Header.Set("Content-Type", "application/json")
resp := httptest.NewRecorder() resp := httptest.NewRecorder()
router.ServeHTTP(resp, r) router.ServeHTTP(resp, r)
@ -408,7 +408,8 @@ func TestListMiddleware(t *testing.T) {
Name: "test-model", Name: "test-model",
ModifiedAt: time.Unix(int64(1686935002), 0).UTC(), ModifiedAt: time.Unix(int64(1686935002), 0).UTC(),
}, },
}}) },
})
}, },
body: `{ body: `{
"object": "list", "object": "list",