@@ -101,92 +101,68 @@ func Test_hasFilter(t *testing.T) {
101
101
}
102
102
}
103
103
104
- func Test_extractRepoFilter (t * testing.T ) {
104
+ func Test_hasRepoFilter (t * testing.T ) {
105
105
tests := []struct {
106
- name string
107
- query string
108
- expectedOwner string
109
- expectedRepo string
110
- expectedFound bool
106
+ name string
107
+ query string
108
+ expected bool
111
109
}{
112
110
{
113
- name : "query with repo: filter at beginning" ,
114
- query : "repo:github/github-mcp-server is:issue" ,
115
- expectedOwner : "github" ,
116
- expectedRepo : "github-mcp-server" ,
117
- expectedFound : true ,
111
+ name : "query with repo: filter at beginning" ,
112
+ query : "repo:github/github-mcp-server is:issue" ,
113
+ expected : true ,
118
114
},
119
115
{
120
- name : "query with repo: filter in middle" ,
121
- query : "is:issue repo:octocat/Hello-World bug" ,
122
- expectedOwner : "octocat" ,
123
- expectedRepo : "Hello-World" ,
124
- expectedFound : true ,
116
+ name : "query with repo: filter in middle" ,
117
+ query : "is:issue repo:octocat/Hello-World bug" ,
118
+ expected : true ,
125
119
},
126
120
{
127
- name : "query with repo: filter at end" ,
128
- query : "is:issue critical repo:owner/repo-name" ,
129
- expectedOwner : "owner" ,
130
- expectedRepo : "repo-name" ,
131
- expectedFound : true ,
121
+ name : "query with repo: filter at end" ,
122
+ query : "is:issue critical repo:owner/repo-name" ,
123
+ expected : true ,
132
124
},
133
125
{
134
- name : "query with complex repo name" ,
135
- query : "repo:microsoft/vscode-extension-samples bug" ,
136
- expectedOwner : "microsoft" ,
137
- expectedRepo : "vscode-extension-samples" ,
138
- expectedFound : true ,
126
+ name : "query with complex repo name" ,
127
+ query : "repo:microsoft/vscode-extension-samples bug" ,
128
+ expected : true ,
139
129
},
140
130
{
141
- name : "query without repo: filter" ,
142
- query : "is:issue bug critical" ,
143
- expectedOwner : "" ,
144
- expectedRepo : "" ,
145
- expectedFound : false ,
131
+ name : "query without repo: filter" ,
132
+ query : "is:issue bug critical" ,
133
+ expected : false ,
146
134
},
147
135
{
148
- name : "query with malformed repo: filter (no slash)" ,
149
- query : "repo:github bug" ,
150
- expectedOwner : "" ,
151
- expectedRepo : "" ,
152
- expectedFound : false ,
136
+ name : "query with malformed repo: filter (no slash)" ,
137
+ query : "repo:github bug" ,
138
+ expected : true , // hasRepoFilter only checks for repo: prefix, not format
153
139
},
154
140
{
155
- name : "empty query" ,
156
- query : "" ,
157
- expectedOwner : "" ,
158
- expectedRepo : "" ,
159
- expectedFound : false ,
141
+ name : "empty query" ,
142
+ query : "" ,
143
+ expected : false ,
160
144
},
161
145
{
162
- name : "query with multiple repo: filters (should match first)" ,
163
- query : "repo:github/first repo:octocat/second" ,
164
- expectedOwner : "github" ,
165
- expectedRepo : "first" ,
166
- expectedFound : true ,
146
+ name : "query with multiple repo: filters" ,
147
+ query : "repo:github/first repo:octocat/second" ,
148
+ expected : true ,
167
149
},
168
150
{
169
- name : "query with repo: in text but not as filter" ,
170
- query : "this repo: is important" ,
171
- expectedOwner : "" ,
172
- expectedRepo : "" ,
173
- expectedFound : false ,
151
+ name : "query with repo: in text but not as filter" ,
152
+ query : "this repo: is important" ,
153
+ expected : false ,
174
154
},
175
155
{
176
- name : "query with complex OR expression" ,
177
- query : "repo:github/github-mcp-server is:issue (label:critical OR label:urgent)" ,
178
- expectedOwner : "github" ,
179
- expectedRepo : "github-mcp-server" ,
180
- expectedFound : true ,
156
+ name : "query with complex OR expression" ,
157
+ query : "repo:github/github-mcp-server is:issue (label:critical OR label:urgent)" ,
158
+ expected : true ,
181
159
},
182
160
}
183
161
184
162
for _ , tt := range tests {
185
163
t .Run (tt .name , func (t * testing.T ) {
186
- owner , repo , found := extractRepoFilter (tt .query )
187
- assert .Equal (t , tt .expectedOwner , owner , "extractRepoFilter(%q) owner = %q, expected %q" , tt .query , owner , tt .expectedOwner )
188
- assert .Equal (t , tt .expectedRepo , repo , "extractRepoFilter(%q) repo = %q, expected %q" , tt .query , repo , tt .expectedRepo )
189
- assert .Equal (t , tt .expectedFound , found , "extractRepoFilter(%q) found = %v, expected %v" , tt .query , found , tt .expectedFound )
164
+ result := hasRepoFilter (tt .query )
165
+ assert .Equal (t , tt .expected , result , "hasRepoFilter(%q) = %v, expected %v" , tt .query , result , tt .expected )
190
166
})
191
167
}
192
168
}
0 commit comments