Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
41
backend/sdk/cliproxy/service_models_config_index_test.go
Normal file
41
backend/sdk/cliproxy/service_models_config_index_test.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package cliproxy
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/router-for-me/CLIProxyAPI/v7/internal/config"
|
||||
coreauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth"
|
||||
)
|
||||
|
||||
func TestOpenAICompatibilityRegistrationCacheUsesConfigIndex(t *testing.T) {
|
||||
service := &Service{cfg: &config.Config{OpenAICompatibility: []config.OpenAICompatibility{
|
||||
{Name: "shared", Models: []config.OpenAICompatibilityModel{{Name: "first"}}},
|
||||
{Name: "shared", Models: []config.OpenAICompatibilityModel{{Name: "second"}}},
|
||||
}}}
|
||||
cache := service.newOpenAICompatibilityRegistrationCache()
|
||||
auth := &coreauth.Auth{Attributes: map[string]string{
|
||||
coreauth.AttributeSource: "config:shared[token-1]",
|
||||
coreauth.AttributeConfigIndex: "1",
|
||||
}}
|
||||
entry, ok := cache.lookup(auth, "shared")
|
||||
if !ok || entry == nil || len(entry.models) != 1 || entry.models[0].ID != "second" {
|
||||
t.Fatalf("cached config entry = %+v, want second model", entry)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveConfigClaudeKeyUsesConfigIndex(t *testing.T) {
|
||||
service := &Service{cfg: &config.Config{ClaudeKey: []config.ClaudeKey{
|
||||
{APIKey: "shared-key", Models: []config.ClaudeModel{{Name: "first"}}},
|
||||
{APIKey: "shared-key", Models: []config.ClaudeModel{{Name: "second"}}},
|
||||
}}}
|
||||
auth := &coreauth.Auth{Attributes: map[string]string{
|
||||
coreauth.AttributeAPIKey: "shared-key",
|
||||
coreauth.AttributeSource: "config:claude[token-1]",
|
||||
coreauth.AttributeConfigIndex: "1",
|
||||
}}
|
||||
|
||||
entry := service.resolveConfigClaudeKey(auth)
|
||||
if entry == nil || len(entry.Models) != 1 || entry.Models[0].Name != "second" {
|
||||
t.Fatalf("resolved config entry = %+v, want second entry", entry)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue