mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-05-11 00:11:36 +08:00
- Updated all references from v6 to v7 for `github.com/router-for-me/CLIProxyAPI`. - Ensured consistency in imports within core libraries, tests, and integration tests. - Added missing tests for new features in Redis Protocol integration.
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package cliproxy
|
|
|
|
import (
|
|
"testing"
|
|
|
|
coreauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth"
|
|
"github.com/router-for-me/CLIProxyAPI/v7/sdk/config"
|
|
)
|
|
|
|
func TestEnsureExecutorsForAuth_CodexDoesNotReplaceInNormalMode(t *testing.T) {
|
|
service := &Service{
|
|
cfg: &config.Config{},
|
|
coreManager: coreauth.NewManager(nil, nil, nil),
|
|
}
|
|
auth := &coreauth.Auth{
|
|
ID: "codex-auth-1",
|
|
Provider: "codex",
|
|
Status: coreauth.StatusActive,
|
|
}
|
|
|
|
service.ensureExecutorsForAuth(auth)
|
|
firstExecutor, okFirst := service.coreManager.Executor("codex")
|
|
if !okFirst || firstExecutor == nil {
|
|
t.Fatal("expected codex executor after first bind")
|
|
}
|
|
|
|
service.ensureExecutorsForAuth(auth)
|
|
secondExecutor, okSecond := service.coreManager.Executor("codex")
|
|
if !okSecond || secondExecutor == nil {
|
|
t.Fatal("expected codex executor after second bind")
|
|
}
|
|
|
|
if firstExecutor != secondExecutor {
|
|
t.Fatal("expected codex executor to stay unchanged in normal mode")
|
|
}
|
|
}
|
|
|
|
func TestEnsureExecutorsForAuthWithMode_CodexForceReplace(t *testing.T) {
|
|
service := &Service{
|
|
cfg: &config.Config{},
|
|
coreManager: coreauth.NewManager(nil, nil, nil),
|
|
}
|
|
auth := &coreauth.Auth{
|
|
ID: "codex-auth-2",
|
|
Provider: "codex",
|
|
Status: coreauth.StatusActive,
|
|
}
|
|
|
|
service.ensureExecutorsForAuth(auth)
|
|
firstExecutor, okFirst := service.coreManager.Executor("codex")
|
|
if !okFirst || firstExecutor == nil {
|
|
t.Fatal("expected codex executor after first bind")
|
|
}
|
|
|
|
service.ensureExecutorsForAuthWithMode(auth, true)
|
|
secondExecutor, okSecond := service.coreManager.Executor("codex")
|
|
if !okSecond || secondExecutor == nil {
|
|
t.Fatal("expected codex executor after forced rebind")
|
|
}
|
|
|
|
if firstExecutor == secondExecutor {
|
|
t.Fatal("expected codex executor replacement in force mode")
|
|
}
|
|
}
|