Download sdk/cliproxy/service_oauth_model_alias_test.go from shimen/API: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/spaces/shimen/API/resolve/main/sdk/cliproxy/service_oauth_model_alias_test.go
- Command line
-
hf download hf://spaces/shimen/API/sdk/cliproxy/service_oauth_model_alias_test.go
-
curl -L -o service_oauth_model_alias_test.go https://huggingface.co/spaces/shimen/API/resolve/main/sdk/cliproxy/service_oauth_model_alias_test.go
2.41 kB
| package cliproxy | |
| import ( | |
| "testing" | |
| "github.com/router-for-me/CLIProxyAPI/v6/sdk/config" | |
| ) | |
| func TestApplyOAuthModelAlias_Rename(t *testing.T) { | |
| cfg := &config.Config{ | |
| OAuthModelAlias: map[string][]config.OAuthModelAlias{ | |
| "codex": { | |
| {Name: "gpt-5", Alias: "g5"}, | |
| }, | |
| }, | |
| } | |
| models := []*ModelInfo{ | |
| {ID: "gpt-5", Name: "models/gpt-5"}, | |
| } | |
| out := applyOAuthModelAlias(cfg, "codex", "oauth", models) | |
| if len(out) != 1 { | |
| t.Fatalf("expected 1 model, got %d", len(out)) | |
| } | |
| if out[0].ID != "g5" { | |
| t.Fatalf("expected model id %q, got %q", "g5", out[0].ID) | |
| } | |
| if out[0].Name != "models/g5" { | |
| t.Fatalf("expected model name %q, got %q", "models/g5", out[0].Name) | |
| } | |
| } | |
| func TestApplyOAuthModelAlias_ForkAddsAlias(t *testing.T) { | |
| cfg := &config.Config{ | |
| OAuthModelAlias: map[string][]config.OAuthModelAlias{ | |
| "codex": { | |
| {Name: "gpt-5", Alias: "g5", Fork: true}, | |
| }, | |
| }, | |
| } | |
| models := []*ModelInfo{ | |
| {ID: "gpt-5", Name: "models/gpt-5"}, | |
| } | |
| out := applyOAuthModelAlias(cfg, "codex", "oauth", models) | |
| if len(out) != 2 { | |
| t.Fatalf("expected 2 models, got %d", len(out)) | |
| } | |
| if out[0].ID != "gpt-5" { | |
| t.Fatalf("expected first model id %q, got %q", "gpt-5", out[0].ID) | |
| } | |
| if out[1].ID != "g5" { | |
| t.Fatalf("expected second model id %q, got %q", "g5", out[1].ID) | |
| } | |
| if out[1].Name != "models/g5" { | |
| t.Fatalf("expected forked model name %q, got %q", "models/g5", out[1].Name) | |
| } | |
| } | |
| func TestApplyOAuthModelAlias_ForkAddsMultipleAliases(t *testing.T) { | |
| cfg := &config.Config{ | |
| OAuthModelAlias: map[string][]config.OAuthModelAlias{ | |
| "codex": { | |
| {Name: "gpt-5", Alias: "g5", Fork: true}, | |
| {Name: "gpt-5", Alias: "g5-2", Fork: true}, | |
| }, | |
| }, | |
| } | |
| models := []*ModelInfo{ | |
| {ID: "gpt-5", Name: "models/gpt-5"}, | |
| } | |
| out := applyOAuthModelAlias(cfg, "codex", "oauth", models) | |
| if len(out) != 3 { | |
| t.Fatalf("expected 3 models, got %d", len(out)) | |
| } | |
| if out[0].ID != "gpt-5" { | |
| t.Fatalf("expected first model id %q, got %q", "gpt-5", out[0].ID) | |
| } | |
| if out[1].ID != "g5" { | |
| t.Fatalf("expected second model id %q, got %q", "g5", out[1].ID) | |
| } | |
| if out[1].Name != "models/g5" { | |
| t.Fatalf("expected forked model name %q, got %q", "models/g5", out[1].Name) | |
| } | |
| if out[2].ID != "g5-2" { | |
| t.Fatalf("expected third model id %q, got %q", "g5-2", out[2].ID) | |
| } | |
| if out[2].Name != "models/g5-2" { | |
| t.Fatalf("expected forked model name %q, got %q", "models/g5-2", out[2].Name) | |
| } | |
| } | |