@@ -101,92 +101,68 @@ func Test_hasFilter(t *testing.T) {
101101 }
102102}
103103
104- func Test_extractRepoFilter (t * testing.T ) {
104+ func Test_hasRepoFilter (t * testing.T ) {
105105 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
111109 }{
112110 {
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 ,
118114 },
119115 {
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 ,
125119 },
126120 {
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 ,
132124 },
133125 {
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 ,
139129 },
140130 {
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 ,
146134 },
147135 {
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
153139 },
154140 {
155- name : "empty query" ,
156- query : "" ,
157- expectedOwner : "" ,
158- expectedRepo : "" ,
159- expectedFound : false ,
141+ name : "empty query" ,
142+ query : "" ,
143+ expected : false ,
160144 },
161145 {
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 ,
167149 },
168150 {
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 ,
174154 },
175155 {
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 ,
181159 },
182160 }
183161
184162 for _ , tt := range tests {
185163 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 )
190166 })
191167 }
192168}
0 commit comments