MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestSessionTaskKey

Function TestSessionTaskKey

internal/llm/sessionkey_test.go:45–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestSessionTaskKey(t *testing.T) {
46 if got := SessionTaskKey("sess", "", ""); got != "sess" {
47 t.Errorf("SessionTaskKey(sess,,) = %q, want %q", got, "sess")
48 }
49 if got := SessionTaskKey("sess", "plan_task", ""); got != "sess-plan_task" {
50 t.Errorf("SessionTaskKey without scope = %q, want %q", got, "sess-plan_task")
51 }
52 if got := SessionTaskKey("01234567-89ab-4cde-8fab-0123456789ab", "", ""); got != "01234567" {
53 t.Errorf("SessionTaskKey with UUID only = %q, want %q", got, "01234567")
54 }
55
56 k1 := SessionTaskKey("sess", "main_task", "a/b.go")
57 k2 := SessionTaskKey("sess", "main_task", "a/b.go")
58 if k1 != k2 {
59 t.Errorf("SessionTaskKey not deterministic: %q != %q", k1, k2)
60 }
61 if !strings.HasPrefix(k1, "sess-main_task-") {
62 t.Errorf("SessionTaskKey = %q, want prefix %q", k1, "sess-main_task-")
63 }
64 if k1 == SessionTaskKey("sess", "main_task", "a/c.go") {
65 t.Error("different scopes must produce different keys")
66 }
67 if k1 == SessionTaskKey("sess", "plan_task", "a/b.go") {
68 t.Error("different task types must produce different keys")
69 }
70 // Non-ASCII scopes must still yield a header-safe key.
71 for _, r := range SessionTaskKey("sess", "main_task", "文件/경로.go") { // allow-non-english: fixture exercises non-ASCII path hashing
72 if r <= ' ' || r > '~' {
73 t.Errorf("SessionTaskKey produced non header-safe rune %q", r)
74 }
75 }
76}
77
78func TestSessionTaskKeyProviderSafeLength(t *testing.T) {
79 sessionKey := "00000000-0000-4000-8000-000000000000"

Callers

nothing calls this directly

Calls 2

SessionTaskKeyFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected