Sub2API v1.0 - AI API 网关(二开初始版本,基于上游 Wei-Shaw/sub2api)
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestShouldFailoverUpstreamError_405IsFailoverEligible(t *testing.T) {
|
||||
svc := &OpenAIGatewayService{}
|
||||
|
||||
assert.True(t, svc.shouldFailoverUpstreamError(http.StatusMethodNotAllowed),
|
||||
"405 should trigger failover so sticky sessions can escape to healthy accounts")
|
||||
}
|
||||
|
||||
func TestShouldFailoverUpstreamError_ExistingCodesStillWork(t *testing.T) {
|
||||
svc := &OpenAIGatewayService{}
|
||||
|
||||
failoverCodes := []int{401, 402, 403, 405, 429, 529, 500, 502, 503, 504}
|
||||
for _, code := range failoverCodes {
|
||||
assert.True(t, svc.shouldFailoverUpstreamError(code), "status %d should trigger failover", code)
|
||||
}
|
||||
|
||||
nonFailoverCodes := []int{200, 201, 400, 404, 408, 422}
|
||||
for _, code := range nonFailoverCodes {
|
||||
assert.False(t, svc.shouldFailoverUpstreamError(code), "status %d should NOT trigger failover", code)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user