Skip to content

Commit 22575db

Browse files
committed
fix: api-test
1 parent b911094 commit 22575db

File tree

5 files changed

+17
-46
lines changed

5 files changed

+17
-46
lines changed

.claude/settings.local.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ tmp/codegraph/*.profile
1818
.coignore
1919
.documents
2020
.cospec
21+
.claude
2122
internal/service/*.profile

test/api/query_callgraph_test.go

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ type queryCallGraphTestCase struct {
2323
clientId string
2424
codebasePath string
2525
filePath string
26-
startLine int
27-
endLine int
26+
lineRange string
2827
symbolName string
2928
maxLayer int
3029
expectedStatus int
@@ -40,8 +39,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
4039
clientId: "123",
4140
codebasePath: s.workspacePath,
4241
filePath: filepath.Join(s.workspacePath, "test", "api", "query_reference_test.go"),
43-
startLine: 1,
44-
endLine: 1000,
42+
lineRange: "1-1000",
4543
symbolName: "",
4644
maxLayer: 3,
4745
expectedStatus: http.StatusOK,
@@ -60,7 +58,6 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
6058
assert.Contains(t, firstItem, "filePath")
6159
assert.Contains(t, firstItem, "symbolName")
6260
assert.Contains(t, firstItem, "position")
63-
assert.Contains(t, firstItem, "content")
6461
assert.Contains(t, firstItem, "nodeType")
6562

6663
position := firstItem["position"].(map[string]interface{})
@@ -87,8 +84,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
8784
clientId: "123",
8885
codebasePath: s.workspacePath,
8986
filePath: filepath.Join(s.workspacePath, "test", "api", "query_reference_test.go"),
90-
startLine: 1,
91-
endLine: 1000,
87+
lineRange: "",
9288
symbolName: "TestQueryReference",
9389
maxLayer: 2,
9490
expectedStatus: http.StatusOK,
@@ -106,8 +102,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
106102
name: "缺少codebasePath参数",
107103
clientId: "123",
108104
filePath: filepath.Join(s.workspacePath, "test", "api", "query_reference_test.go"),
109-
startLine: 1,
110-
endLine: 1000,
105+
lineRange: "1-1000",
111106
symbolName: "",
112107
maxLayer: 3,
113108
expectedStatus: http.StatusBadRequest,
@@ -119,8 +114,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
119114
name: "缺少filePath参数",
120115
clientId: "123",
121116
codebasePath: s.workspacePath,
122-
startLine: 1,
123-
endLine: 1000,
117+
lineRange: "1-1000",
124118
symbolName: "",
125119
maxLayer: 3,
126120
expectedStatus: http.StatusBadRequest,
@@ -133,8 +127,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
133127
clientId: "123",
134128
codebasePath: s.workspacePath,
135129
filePath: filepath.Join(s.workspacePath, "test", "api", "no_exists.go"),
136-
startLine: 1,
137-
endLine: 1000,
130+
lineRange: "1-1000",
138131
symbolName: "",
139132
maxLayer: 3,
140133
expectedStatus: http.StatusBadRequest,
@@ -148,8 +141,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
148141
clientId: "",
149142
codebasePath: "",
150143
filePath: "",
151-
startLine: 0,
152-
endLine: 0,
144+
lineRange: "",
153145
symbolName: "",
154146
maxLayer: 0,
155147
expectedStatus: http.StatusBadRequest,
@@ -162,8 +154,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
162154
clientId: "123",
163155
codebasePath: s.workspacePath,
164156
filePath: filepath.Join(s.workspacePath, "test", "api", "query_reference_test.go"),
165-
startLine: 1,
166-
endLine: 1000,
157+
lineRange: "1-1000",
167158
symbolName: "",
168159
maxLayer: 10, // 测试最大层数
169160
expectedStatus: http.StatusOK,
@@ -182,8 +173,7 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
182173
clientId: "123",
183174
codebasePath: s.workspacePath,
184175
filePath: filepath.Join(s.workspacePath, "test", "api", "query_reference_test.go"),
185-
startLine: 30,
186-
endLine: 50,
176+
lineRange: "30-50",
187177
symbolName: "",
188178
maxLayer: 2,
189179
expectedStatus: http.StatusOK,
@@ -217,11 +207,8 @@ func (s *QueryCallGraphIntegrationTestSuite) TestQueryCallGraph() {
217207
if tc.filePath != "" {
218208
q.Add("filePath", tc.filePath)
219209
}
220-
if tc.startLine > 0 {
221-
q.Add("startLine", fmt.Sprintf("%d", tc.startLine))
222-
}
223-
if tc.endLine > 0 {
224-
q.Add("endLine", fmt.Sprintf("%d", tc.endLine))
210+
if tc.lineRange != "" {
211+
q.Add("lineRange", tc.lineRange)
225212
}
226213
if tc.symbolName != "" {
227214
q.Add("symbolName", tc.symbolName)

test/api/query_definition_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func (s *QueryDefinitionIntegrationTestSuite) TestQueryDefinition() {
5555
assert.Contains(t, firstItem, "filePath")
5656
assert.Contains(t, firstItem, "name")
5757
assert.Contains(t, firstItem, "type")
58-
assert.Contains(t, firstItem, "content")
5958
assert.Contains(t, firstItem, "position")
6059

6160
position := firstItem["position"].(map[string]interface{})
@@ -154,7 +153,6 @@ func (s *QueryDefinitionIntegrationTestSuite) TestQueryDefinition() {
154153
assert.Contains(t, firstItem, "filePath")
155154
assert.Contains(t, firstItem, "name")
156155
assert.Contains(t, firstItem, "type")
157-
assert.Contains(t, firstItem, "content")
158156
assert.Contains(t, firstItem, "position")
159157

160158
// 验证符号名称匹配
@@ -230,7 +228,7 @@ func (s *QueryDefinitionIntegrationTestSuite) TestQueryDefinition() {
230228
q.Add("filePath", tc.filePath)
231229
}
232230
if tc.symbolName != "" {
233-
q.Add("symbolName", tc.symbolName)
231+
q.Add("symbolNames", tc.symbolName)
234232
}
235233
if tc.startLine > 0 {
236234
q.Add("startLine", fmt.Sprintf("%d", tc.startLine))

test/api/rebuild_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s *IndexIntegrationTestSuite) TestIndex() {
6767
indexType: "codegraph",
6868

6969
expectedStatus: http.StatusBadRequest,
70-
expectedCode: "400", // 假设错误码为1
70+
expectedCode: "codebase-indexer.bad_request",
7171
validateResp: func(t *testing.T, response map[string]interface{}) {
7272
assert.False(t, response["success"].(bool))
7373
assert.NotEmpty(t, response["message"])
@@ -78,7 +78,7 @@ func (s *IndexIntegrationTestSuite) TestIndex() {
7878
workspace: s.workspacePath,
7979

8080
expectedStatus: http.StatusBadRequest,
81-
expectedCode: "400",
81+
expectedCode: "codebase-indexer.bad_request",
8282
validateResp: func(t *testing.T, response map[string]interface{}) {
8383
assert.False(t, response["success"].(bool))
8484
},
@@ -89,15 +89,15 @@ func (s *IndexIntegrationTestSuite) TestIndex() {
8989
indexType: "invalid-type", // 无效的索引类型
9090

9191
expectedStatus: http.StatusBadRequest,
92-
expectedCode: "400", // 假设无效类型错误码为2
92+
expectedCode: "codebase-indexer.bad_request", // 假设无效类型错误码为2
9393
},
9494
{
9595
name: "无效的JSON请求体",
9696
workspace: s.workspacePath,
9797
indexType: "codegraph",
9898

9999
expectedStatus: http.StatusBadRequest,
100-
expectedCode: "400",
100+
expectedCode: "codebase-indexer.bad_request",
101101
isInvalidJSON: true,
102102
},
103103
}

0 commit comments

Comments
 (0)