-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathcursor_executor_buildrequest_test.go
More file actions
57 lines (54 loc) · 1.65 KB
/
Copy pathcursor_executor_buildrequest_test.go
File metadata and controls
57 lines (54 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package executor
import "testing"
// TestBuildRunRequestParams_ModelOverride verifies that buildRunRequestParams
// honors the modelOverride parameter when supplied (so the upstream Cursor Run
// call receives the resolved model name from an oauth-model-alias entry),
// and falls back to parsed.Model when the override is empty or whitespace.
func TestBuildRunRequestParams_ModelOverride(t *testing.T) {
tests := []struct {
name string
parsedModel string
override string
wantModelId string
}{
{
name: "override wins over parsed.Model",
parsedModel: "cursor/composer-2.5",
override: "composer-2.5",
wantModelId: "composer-2.5",
},
{
name: "empty override falls back to parsed.Model",
parsedModel: "composer-2.5",
override: "",
wantModelId: "composer-2.5",
},
{
name: "whitespace override falls back to parsed.Model",
parsedModel: "composer-2.5",
override: " \t ",
wantModelId: "composer-2.5",
},
{
name: "override wins even when parsed.Model is empty",
parsedModel: "",
override: "composer-2.5",
wantModelId: "composer-2.5",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
parsed := &parsedOpenAIRequest{Model: tc.parsedModel}
params := buildRunRequestParams(parsed, "conv-123", tc.override)
if params == nil {
t.Fatal("buildRunRequestParams returned nil")
}
if params.ModelId != tc.wantModelId {
t.Errorf("ModelId = %q, want %q", params.ModelId, tc.wantModelId)
}
if params.ConversationId != "conv-123" {
t.Errorf("ConversationId = %q, want %q", params.ConversationId, "conv-123")
}
})
}
}