@@ -37,29 +37,44 @@ func TestFindClosingPullRequestsIntegration(t *testing.T) {
37
37
// Test cases with known GitHub issues that were closed by PRs
38
38
testCases := []struct {
39
39
name string
40
- issues []string
40
+ owner string
41
+ repo string
42
+ issueNumbers []int
43
+ issueReferences []string
41
44
expectedResults int
42
45
expectSomeClosingPRs bool
43
46
expectSpecificIssue string
44
47
expectSpecificPRNumber int
45
48
}{
46
49
{
47
- name : "Single issue - VS Code well-known closed issue" ,
48
- issues : []string {"microsoft/vscode#123456" }, // This is a made-up issue for testing
50
+ name : "Single issue using issue_numbers - VS Code well-known closed issue" ,
51
+ owner : "microsoft" ,
52
+ repo : "vscode" ,
53
+ issueNumbers : []int {123456 }, // This is a made-up issue for testing
49
54
expectedResults : 1 ,
50
55
expectSomeClosingPRs : false , // We expect this to not exist or have no closing PRs
51
56
},
52
57
{
53
- name : "Multiple issues with mixed results" ,
54
- issues : []string {"octocat/Hello-World#1" , "microsoft/vscode#999999" },
58
+ name : "Multiple issues using issue_numbers with mixed results" ,
59
+ owner : "microsoft" ,
60
+ repo : "vscode" ,
61
+ issueNumbers : []int {1 , 999999 },
55
62
expectedResults : 2 ,
56
63
expectSomeClosingPRs : false , // These are likely non-existent or have no closing PRs
57
64
},
58
65
{
59
- name : "Issue from a popular repo - React" ,
60
- issues : []string {"facebook/react#1" }, // Very first issue in React repo
66
+ name : "Issue from a popular repo using issue_numbers - React" ,
67
+ owner : "facebook" ,
68
+ repo : "react" ,
69
+ issueNumbers : []int {1 }, // Very first issue in React repo
61
70
expectedResults : 1 ,
62
71
},
72
+ {
73
+ name : "Cross-repository queries using issue_references" ,
74
+ issueReferences : []string {"octocat/Hello-World#1" , "facebook/react#1" },
75
+ expectedResults : 2 ,
76
+ expectSomeClosingPRs : false , // These might have closing PRs
77
+ },
63
78
}
64
79
65
80
ctx := context .Background ()
@@ -68,8 +83,16 @@ func TestFindClosingPullRequestsIntegration(t *testing.T) {
68
83
t .Run (tc .name , func (t * testing.T ) {
69
84
// Create request arguments
70
85
args := map [string ]interface {}{
71
- "issues" : tc .issues ,
72
- "limit" : 5 ,
86
+ "limit" : 5 ,
87
+ }
88
+
89
+ // Add appropriate parameters based on test case
90
+ if len (tc .issueNumbers ) > 0 {
91
+ args ["owner" ] = tc .owner
92
+ args ["repo" ] = tc .repo
93
+ args ["issue_numbers" ] = tc .issueNumbers
94
+ } else if len (tc .issueReferences ) > 0 {
95
+ args ["issue_references" ] = tc .issueReferences
73
96
}
74
97
75
98
// Create mock request
@@ -101,7 +124,7 @@ func TestFindClosingPullRequestsIntegration(t *testing.T) {
101
124
102
125
// Parse JSON response
103
126
var response struct {
104
- Results []FindClosingPRsResult `json:"results"`
127
+ Results []map [ string ] interface {} `json:"results"`
105
128
}
106
129
err := json .Unmarshal ([]byte (textResult ), & response )
107
130
require .NoError (t , err , "Failed to parse JSON response" )
@@ -110,35 +133,28 @@ func TestFindClosingPullRequestsIntegration(t *testing.T) {
110
133
assert .Len (t , response .Results , tc .expectedResults , "Expected specific number of results" )
111
134
112
135
for i , result := range response .Results {
113
- t .Logf ("Issue %d: %s" , i + 1 , result .Issue )
114
- t .Logf (" Owner: %s, Repo: %s, Number: %d" , result .Owner , result .Repo , result .IssueNumber )
115
- t .Logf (" Total closing PRs: %d" , result .TotalCount )
116
- t .Logf (" Error: %s" , result .Error )
136
+ t .Logf ("Issue %d:" , i + 1 )
137
+ t .Logf (" Owner: %v, Repo: %v, Number: %v" , result ["owner" ], result ["repo" ], result ["issue_number" ])
138
+ t .Logf (" Total closing PRs: %v" , result ["total_count" ])
117
139
118
- // Verify basic structure
119
- assert .NotEmpty (t , result .Issue , "Issue reference should not be empty" )
120
- assert .NotEmpty (t , result .Owner , "Owner should not be empty" )
121
- assert .NotEmpty (t , result .Repo , "Repo should not be empty" )
122
- assert .Greater (t , result .IssueNumber , 0 , "Issue number should be positive" )
123
-
124
- // Log closing PRs if any
125
- for j , pr := range result .ClosingPullRequests {
126
- t .Logf (" PR %d: #%d - %s" , j + 1 , pr .Number , pr .Title )
127
- t .Logf (" State: %s, Merged: %t" , pr .State , pr .Merged )
128
- t .Logf (" URL: %s" , pr .URL )
140
+ if errorMsg , hasError := result ["error" ]; hasError {
141
+ t .Logf (" Error: %v" , errorMsg )
129
142
}
130
143
131
- // Check for expected specific results
132
- if tc .expectSpecificIssue != "" && result .Issue == tc .expectSpecificIssue {
133
- if tc .expectSpecificPRNumber > 0 {
134
- found := false
135
- for _ , pr := range result .ClosingPullRequests {
136
- if pr .Number == tc .expectSpecificPRNumber {
137
- found = true
138
- break
139
- }
144
+ // Verify basic structure
145
+ assert .NotEmpty (t , result ["owner" ], "Owner should not be empty" )
146
+ assert .NotEmpty (t , result ["repo" ], "Repo should not be empty" )
147
+ assert .NotNil (t , result ["issue_number" ], "Issue number should not be nil" )
148
+
149
+ // Check closing PRs if any
150
+ if closingPRs , ok := result ["closing_pull_requests" ].([]interface {}); ok {
151
+ t .Logf (" Found %d closing PRs" , len (closingPRs ))
152
+ for j , pr := range closingPRs {
153
+ if prMap , ok := pr .(map [string ]interface {}); ok {
154
+ t .Logf (" PR %d: #%v - %v" , j + 1 , prMap ["number" ], prMap ["title" ])
155
+ t .Logf (" State: %v, Merged: %v" , prMap ["state" ], prMap ["merged" ])
156
+ t .Logf (" URL: %v" , prMap ["url" ])
140
157
}
141
- assert .True (t , found , "Expected to find specific PR number" )
142
158
}
143
159
}
144
160
}
0 commit comments