@@ -2,6 +2,7 @@ package github
22
33import (
44 "context"
5+ "encoding/json"
56 "net/http"
67 "strings"
78 "testing"
@@ -458,6 +459,70 @@ func TestGranularUpdateIssueType(t *testing.T) {
458459 }
459460}
460461
462+ func TestGranularUpdateIssueTypeSuggest (t * testing.T ) {
463+ tests := []struct {
464+ name string
465+ requestArgs map [string ]any
466+ expected map [string ]any
467+ }{
468+ {
469+ name : "suggest without rationale" ,
470+ requestArgs : map [string ]any {
471+ "owner" : "owner" ,
472+ "repo" : "repo" ,
473+ "issue_number" : float64 (1 ),
474+ "issue_type" : "bug" ,
475+ "suggest" : true ,
476+ },
477+ expected : map [string ]any {
478+ "owner" : "owner" ,
479+ "repo" : "repo" ,
480+ "issue_number" : float64 (1 ),
481+ "issue_type" : "bug" ,
482+ "suggested" : true ,
483+ },
484+ },
485+ {
486+ name : "suggest with rationale" ,
487+ requestArgs : map [string ]any {
488+ "owner" : "owner" ,
489+ "repo" : "repo" ,
490+ "issue_number" : float64 (1 ),
491+ "issue_type" : "feature" ,
492+ "rationale" : " Asks for dark mode support " ,
493+ "suggest" : true ,
494+ },
495+ expected : map [string ]any {
496+ "owner" : "owner" ,
497+ "repo" : "repo" ,
498+ "issue_number" : float64 (1 ),
499+ "issue_type" : "feature" ,
500+ "rationale" : "Asks for dark mode support" ,
501+ "suggested" : true ,
502+ },
503+ },
504+ }
505+
506+ for _ , tc := range tests {
507+ t .Run (tc .name , func (t * testing.T ) {
508+ // No HTTP handler registered: any API call would fail the test.
509+ deps := BaseDeps {Client : mustNewGHClient (t , MockHTTPClientWithHandlers (nil ))}
510+ serverTool := GranularUpdateIssueType (translations .NullTranslationHelper )
511+ handler := serverTool .Handler (deps )
512+
513+ request := createMCPRequest (tc .requestArgs )
514+ result , err := handler (ContextWithDeps (context .Background (), deps ), & request )
515+ require .NoError (t , err )
516+ require .False (t , result .IsError )
517+
518+ textContent := getTextResult (t , result )
519+ var got map [string ]any
520+ require .NoError (t , json .Unmarshal ([]byte (textContent .Text ), & got ))
521+ assert .Equal (t , tc .expected , got )
522+ })
523+ }
524+ }
525+
461526func TestGranularUpdateIssueTypeInvalidRationale (t * testing.T ) {
462527 tests := []struct {
463528 name string
0 commit comments