Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
|
|
@ -0,0 +1,57 @@
|
|||
package management
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/router-for-me/CLIProxyAPI/v7/internal/config"
|
||||
)
|
||||
|
||||
func TestPatchXAIKeyUpdatesExecutionFields(t *testing.T) {
|
||||
disableCooling := false
|
||||
h := &Handler{
|
||||
cfg: &config.Config{XAIKey: []config.XAIKey{{
|
||||
APIKey: "xai-key",
|
||||
Priority: 1,
|
||||
BaseURL: "https://api.x.ai/v1",
|
||||
Websockets: true,
|
||||
DisableCooling: &disableCooling,
|
||||
}}},
|
||||
configFilePath: writeTestConfigFile(t),
|
||||
}
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
ctx, _ := gin.CreateTestContext(rec)
|
||||
ctx.Request = httptest.NewRequest(http.MethodPatch, "/v0/management/xai-api-key", strings.NewReader(`{
|
||||
"index": 0,
|
||||
"value": {
|
||||
"priority": 7,
|
||||
"websockets": false,
|
||||
"disable-cooling": true,
|
||||
"request-retry": 0
|
||||
}
|
||||
}`))
|
||||
ctx.Request.Header.Set("Content-Type", "application/json")
|
||||
|
||||
h.PatchXAIKey(ctx)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, want %d; body=%s", rec.Code, http.StatusOK, rec.Body.String())
|
||||
}
|
||||
entry := h.cfg.XAIKey[0]
|
||||
if entry.Priority != 7 {
|
||||
t.Fatalf("priority = %d, want 7", entry.Priority)
|
||||
}
|
||||
if entry.Websockets {
|
||||
t.Fatal("websockets = true, want false")
|
||||
}
|
||||
if entry.DisableCooling == nil || !*entry.DisableCooling {
|
||||
t.Fatalf("disable-cooling = %v, want true", entry.DisableCooling)
|
||||
}
|
||||
if entry.RequestRetry == nil || *entry.RequestRetry != 0 {
|
||||
t.Fatalf("request-retry = %v, want 0", entry.RequestRetry)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue