forked from QuantumNous/new-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoption_claude_test.go
More file actions
34 lines (29 loc) · 873 Bytes
/
Copy pathoption_claude_test.go
File metadata and controls
34 lines (29 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package controller
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/QuantumNous/new-api/common"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestUpdateOptionRejectsNegativeClaudeDefaultMaxTokens(t *testing.T) {
response := httptest.NewRecorder()
context, _ := gin.CreateTestContext(response)
context.Request = httptest.NewRequest(
http.MethodPut,
"/api/option/",
strings.NewReader(`{"key":"claude.default_max_tokens","value":"{\"default\":-1}"}`),
)
UpdateOption(context)
assert.Equal(t, http.StatusOK, response.Code)
var payload struct {
Success bool `json:"success"`
Message string `json:"message"`
}
require.NoError(t, common.Unmarshal(response.Body.Bytes(), &payload))
assert.False(t, payload.Success)
assert.Contains(t, payload.Message, "-1")
}