File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments