Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
32
backend/sdk/cliproxy/builder_weight_validation_test.go
Normal file
32
backend/sdk/cliproxy/builder_weight_validation_test.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package cliproxy
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
internalconfig "github.com/router-for-me/CLIProxyAPI/v7/internal/config"
|
||||
)
|
||||
|
||||
func TestBuilderBuildRejectsInvalidWithConfigCredentialWeight(t *testing.T) {
|
||||
invalidWeight := internalconfig.MaxCredentialWeight + 1
|
||||
cfg := &internalconfig.Config{
|
||||
ClaudeKey: []internalconfig.ClaudeKey{{
|
||||
APIKey: "claude-key",
|
||||
Weight: &invalidWeight,
|
||||
}},
|
||||
}
|
||||
|
||||
service, errBuild := NewBuilder().
|
||||
WithConfig(cfg).
|
||||
WithConfigPath(t.TempDir() + "/config.yaml").
|
||||
Build()
|
||||
if errBuild == nil {
|
||||
t.Fatal("Build() accepted an invalid credential weight")
|
||||
}
|
||||
if service != nil {
|
||||
t.Fatal("Build() returned a service for an invalid credential weight")
|
||||
}
|
||||
if !strings.Contains(errBuild.Error(), "cliproxy: validate credential weights: claude-api-key[0].weight") {
|
||||
t.Fatalf("Build() error = %q, want contextual credential weight path", errBuild)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue