Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
|
|
@ -0,0 +1,69 @@
|
|||
package helps
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
cliproxyexecutor "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/executor"
|
||||
)
|
||||
|
||||
func TestDerivedSessionProviderMappings(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
metadata := map[string]any{cliproxyexecutor.DerivedSessionIDMetadataKey: "ctx:v1:test-root"}
|
||||
codexID := DerivedSessionUUID("codex", metadata)
|
||||
xaiID := DerivedSessionUUID("xai", metadata)
|
||||
if _, errParse := uuid.Parse(codexID); errParse != nil {
|
||||
t.Fatalf("Codex mapping %q is not a UUID: %v", codexID, errParse)
|
||||
}
|
||||
if _, errParse := uuid.Parse(xaiID); errParse != nil {
|
||||
t.Fatalf("xAI mapping %q is not a UUID: %v", xaiID, errParse)
|
||||
}
|
||||
if codexID == xaiID {
|
||||
t.Fatalf("provider namespaces produced the same UUID: %q", codexID)
|
||||
}
|
||||
if repeated := DerivedSessionUUID("codex", metadata); repeated != codexID {
|
||||
t.Fatalf("Codex mapping is not stable: first=%q repeated=%q", codexID, repeated)
|
||||
}
|
||||
|
||||
antigravityID := DerivedAntigravitySessionID(metadata)
|
||||
if matched := regexp.MustCompile(`^-[0-9]+$`).MatchString(antigravityID); !matched {
|
||||
t.Fatalf("Antigravity mapping = %q, want negative decimal", antigravityID)
|
||||
}
|
||||
if repeated := DerivedAntigravitySessionID(metadata); repeated != antigravityID {
|
||||
t.Fatalf("Antigravity mapping is not stable: first=%q repeated=%q", antigravityID, repeated)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderSessionUUIDPrefersExecutionSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
first := map[string]any{
|
||||
cliproxyexecutor.ExecutionSessionMetadataKey: "connection-1",
|
||||
cliproxyexecutor.DerivedSessionIDMetadataKey: "ctx:v1:first-root",
|
||||
}
|
||||
second := map[string]any{
|
||||
cliproxyexecutor.ExecutionSessionMetadataKey: "connection-1",
|
||||
cliproxyexecutor.DerivedSessionIDMetadataKey: "ctx:v1:second-root",
|
||||
}
|
||||
firstID := ProviderSessionUUID("codex", first)
|
||||
secondID := ProviderSessionUUID("codex", second)
|
||||
if firstID == "" || firstID != secondID {
|
||||
t.Fatalf("execution session did not stabilize provider UUID: first=%q second=%q", firstID, secondID)
|
||||
}
|
||||
if firstID == DerivedSessionUUID("codex", first) {
|
||||
t.Fatalf("provider UUID did not prefer execution session: %q", firstID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDerivedSessionProviderMappingsRequireIdentity(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if got := DerivedSessionUUID("codex", nil); got != "" {
|
||||
t.Fatalf("DerivedSessionUUID() = %q, want empty", got)
|
||||
}
|
||||
if got := DerivedAntigravitySessionID(nil); got != "" {
|
||||
t.Fatalf("DerivedAntigravitySessionID() = %q, want empty", got)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue