Skip to content

Commit 64c97be

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
add turnclient mock
1 parent d48c78a commit 64c97be

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

pkg/bot/turn_mock_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package bot
2+
3+
import (
4+
"net/http"
5+
"net/http/httptest"
6+
"testing"
7+
)
8+
9+
// mockTurnServer creates an httptest server that mocks turnclient API responses.
10+
func mockTurnServer(t *testing.T) *httptest.Server {
11+
t.Helper()
12+
13+
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
14+
// Return a simple JSON response that matches turnclient's CheckResponse structure
15+
// This is a minimal valid response for testing purposes
16+
w.Header().Set("Content-Type", "application/json")
17+
_, _ = w.Write([]byte(`{
18+
"timestamp": "2025-11-05T00:00:00Z",
19+
"commit": "abc123",
20+
"pull_request": {
21+
"title": "Test PR",
22+
"author": "testauthor",
23+
"state": "open",
24+
"merged": false,
25+
"draft": false,
26+
"created_at": "2025-11-04T00:00:00Z",
27+
"updated_at": "2025-11-05T00:00:00Z",
28+
"url": "https://github.com/testorg/testrepo/pull/42",
29+
"commits": []
30+
},
31+
"analysis": {
32+
"workflow_state": "APPROVED_WAITING_FOR_MERGE",
33+
"next_action": {},
34+
"state_transitions": [],
35+
"ready_to_merge": true,
36+
"approved": true,
37+
"changes_requested": false,
38+
"review_required": false,
39+
"unresolved_comments": 0,
40+
"blocking_reasons": []
41+
}
42+
}`))
43+
}))
44+
}

0 commit comments

Comments
 (0)