Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
59
backend/sdk/cliproxy/service_plugin_executor_test.go
Normal file
59
backend/sdk/cliproxy/service_plugin_executor_test.go
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
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 TestHasNativeOpenAICompatExecutorConfig(t *testing.T) {
|
||||
service := &Service{
|
||||
cfg: &config.Config{
|
||||
OpenAICompatibility: []config.OpenAICompatibility{
|
||||
{Name: "native-provider", BaseURL: "https://native.example.com/v1"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
auth *coreauth.Auth
|
||||
providerKey string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "config provider",
|
||||
auth: &coreauth.Auth{Provider: "native-provider"},
|
||||
providerKey: "native-provider",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "inline base url",
|
||||
auth: &coreauth.Auth{Provider: "plugin-provider", Attributes: map[string]string{"base_url": "https://compat.example.com/v1"}},
|
||||
providerKey: "plugin-provider",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "compat metadata",
|
||||
auth: &coreauth.Auth{Provider: "openai-compatibility", Attributes: map[string]string{"compat_name": "compat"}},
|
||||
providerKey: "compat",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "plain plugin auth",
|
||||
auth: &coreauth.Auth{Provider: "plugin-provider", Attributes: map[string]string{"api_key": "test"}},
|
||||
providerKey: "plugin-provider",
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := service.hasNativeOpenAICompatExecutorConfig(tt.auth, tt.providerKey, service.cfg)
|
||||
if got != tt.want {
|
||||
t.Fatalf("hasNativeOpenAICompatExecutorConfig() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue