@@ -71,6 +71,15 @@ func TestBuildIssuePrompt(t *testing.T) {
7171 },
7272 contains : []string {"Code Changes (git diff)" , "user description" , "special hint" },
7373 },
74+ {
75+ name : "with available labels" ,
76+ request : models.IssueGenerationRequest {
77+ Description : "user description" ,
78+ Language : "en" ,
79+ AvailableLabels : []string {"bug" , "enhancement" },
80+ },
81+ contains : []string {"Available Labels" , "bug, enhancement" },
82+ },
7483 }
7584
7685 for _ , tt := range tests {
@@ -106,26 +115,6 @@ func TestBuildIssuePrompt_WithTemplate(t *testing.T) {
106115
107116 // Should contain the template
108117 assert .Contains (t , prompt , "Bug Report" )
109-
110- // Should contain the final JSON reminder
111- assert .Contains (t , prompt , "🚨 FINAL REMINDER - CRITICAL OUTPUT REQUIREMENT 🚨" )
112- assert .Contains (t , prompt , "YOU MUST OUTPUT **ONLY** VALID JSON" )
113- assert .Contains (t , prompt , "BEGIN YOUR JSON OUTPUT NOW:" )
114-
115- // Should contain instructions about using template in description field
116- assert .Contains (t , prompt , "The template structure above should be used to FILL the \" description\" field" )
117-
118- // Should contain prohibitions
119- assert .Contains (t , prompt , "❌ DO NOT output prose like \" Here is a high-quality GitHub issue...\" " )
120- assert .Contains (t , prompt , "❌ DO NOT output markdown text directly" )
121-
122- // Verify the reminder is at the end
123- lastIndex := len (prompt ) - 500
124- if lastIndex < 0 {
125- lastIndex = 0
126- }
127- finalSection := prompt [lastIndex :]
128- assert .Contains (t , finalSection , "BEGIN YOUR JSON OUTPUT NOW:" )
129118 })
130119
131120 t .Run ("does NOT add final reminder when no template" , func (t * testing.T ) {
@@ -137,9 +126,8 @@ func TestBuildIssuePrompt_WithTemplate(t *testing.T) {
137126
138127 prompt := gen .buildIssuePrompt (request )
139128
140- // Should NOT contain the final JSON reminder
141- assert .NotContains (t , prompt , "🚨 FINAL REMINDER - CRITICAL OUTPUT REQUIREMENT 🚨" )
142- assert .NotContains (t , prompt , "BEGIN YOUR JSON OUTPUT NOW:" )
129+ // Verification is just that prompt exists and is relevant
130+ assert .Contains (t , prompt , "Code Changes" )
143131 })
144132
145133 t .Run ("includes template in Spanish" , func (t * testing.T ) {
@@ -159,10 +147,6 @@ func TestBuildIssuePrompt_WithTemplate(t *testing.T) {
159147
160148 // Should contain the template
161149 assert .Contains (t , prompt , "Reporte de Bug" )
162-
163- // Should still contain the final JSON reminder (in English for consistency)
164- assert .Contains (t , prompt , "🚨 FINAL REMINDER - CRITICAL OUTPUT REQUIREMENT 🚨" )
165- assert .Contains (t , prompt , "BEGIN YOUR JSON OUTPUT NOW:" )
166150 })
167151
168152 t .Run ("handles template with all fields" , func (t * testing.T ) {
@@ -188,28 +172,11 @@ func TestBuildIssuePrompt_WithTemplate(t *testing.T) {
188172 // Should contain changed files
189173 assert .Contains (t , prompt , "main.go" )
190174 assert .Contains (t , prompt , "test.go" )
191-
192- // Should contain the final reminder
193- assert .Contains (t , prompt , "🚨 FINAL REMINDER - CRITICAL OUTPUT REQUIREMENT 🚨" )
194- assert .Contains (t , prompt , "BEGIN YOUR JSON OUTPUT NOW:" )
195175 })
196176
197177 t .Run ("reminder contains complete JSON structure example" , func (t * testing.T ) {
198- template := & models.IssueTemplate {
199- Name : "Test Template" ,
200- }
201-
202- request := models.IssueGenerationRequest {
203- Template : template ,
204- Language : "en" ,
205- }
206-
207- prompt := gen .buildIssuePrompt (request )
208-
209- // Should show the expected JSON structure
210- assert .Contains (t , prompt , `"title": "string here"` )
211- assert .Contains (t , prompt , `"description": "markdown content following the template structure"` )
212- assert .Contains (t , prompt , `"labels": ["array", "of", "strings"]` )
178+ // This test is now obsolete as structure is enforced by Schema, not prompt text.
179+ // We can remove it or just check nothing.
213180 })
214181}
215182
@@ -268,33 +235,42 @@ func TestParseIssueResponse(t *testing.T) {
268235}
269236
270237func TestCleanLabels (t * testing.T ) {
271- gen := & GeminiIssueContentGenerator {}
272238
273239 tests := []struct {
274- name string
275- input []string
276- expected []string
240+ name string
241+ input []string
242+ availableLabels []string
243+ expected []string
277244 }{
278245 {
279- name : "only allowed labels" ,
280- input : []string {"fix" , "feature" , "bug" , "invalid" },
281- expected : []string {"fix" , "feature" },
246+ name : "default whitelist - allowed" ,
247+ input : []string {"fix" , "feature" , "bug" , "invalid" },
248+ availableLabels : nil ,
249+ expected : []string {"fix" , "feature" , "bug" },
250+ },
251+ {
252+ name : "default whitelist - mixed case" ,
253+ input : []string {" Fix " , "FEATURE" , "test" },
254+ availableLabels : nil ,
255+ expected : []string {"fix" , "feature" , "test" },
282256 },
283257 {
284- name : "mixed case and spaces" ,
285- input : []string {" Fix " , "FEATURE" , "test" },
286- expected : []string {"fix" , "feature" , "test" },
258+ name : "strict available labels" ,
259+ input : []string {"custom-1" , "custom-2" , "fix" },
260+ availableLabels : []string {"custom-1" , "custom-2" },
261+ expected : []string {"custom-1" , "custom-2" },
287262 },
288263 {
289- name : "duplicates" ,
290- input : []string {"fix" , "fix" , "FIX" },
291- expected : []string {"fix" },
264+ name : "strict available labels - excludes non-existent" ,
265+ input : []string {"custom-1" , "random" },
266+ availableLabels : []string {"custom-1" },
267+ expected : []string {"custom-1" },
292268 },
293269 }
294270
295271 for _ , tt := range tests {
296272 t .Run (tt .name , func (t * testing.T ) {
297- result := gen . cleanLabels (tt .input )
273+ result := CleanLabels (tt .input , tt . availableLabels )
298274 assert .ElementsMatch (t , tt .expected , result )
299275 })
300276 }
0 commit comments