Browse Source

fix linter issues

jmorganca 8 months ago
parent
commit
dc04f41eb7
2 changed files with 5 additions and 4 deletions
  1. 1 1
      openai/openai.go
  2. 4 3
      openai/openai_test.go

+ 1 - 1
openai/openai.go

@@ -584,7 +584,7 @@ func (w *BaseWriter) writeError(code int, data []byte) (int, error) {
 	}
 
 	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 {
 		return 0, err
 	}

+ 4 - 3
openai/openai_test.go

@@ -20,7 +20,7 @@ import (
 func capture(req any) gin.HandlerFunc {
 	return func(c *gin.Context) {
 		body, _ := io.ReadAll(c.Request.Body)
-		json.Unmarshal(body, req)
+		_ = json.Unmarshal(body, req)
 		c.Next()
 	}
 }
@@ -200,7 +200,7 @@ func TestChatMiddleware(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")
 			resp := httptest.NewRecorder()
 			router.ServeHTTP(resp, r)
@@ -408,7 +408,8 @@ func TestListMiddleware(t *testing.T) {
 							Name:       "test-model",
 							ModifiedAt: time.Unix(int64(1686935002), 0).UTC(),
 						},
-					}})
+					},
+				})
 			},
 			body: `{
 				"object": "list",