(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func Test_GetCodeQualityFinding(t *testing.T) { |
| 19 | // Verify tool definition once |
| 20 | toolDef := GetCodeQualityFinding(translations.NullTranslationHelper) |
| 21 | require.NoError(t, toolsnaps.Test(toolDef.Tool.Name, toolDef.Tool)) |
| 22 | |
| 23 | assert.Equal(t, "get_code_quality_finding", toolDef.Tool.Name) |
| 24 | assert.NotEmpty(t, toolDef.Tool.Description) |
| 25 | |
| 26 | // InputSchema is of type any, need to cast to *jsonschema.Schema |
| 27 | schema, ok := toolDef.Tool.InputSchema.(*jsonschema.Schema) |
| 28 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 29 | assert.Contains(t, schema.Properties, "owner") |
| 30 | assert.Contains(t, schema.Properties, "repo") |
| 31 | assert.Contains(t, schema.Properties, "findingNumber") |
| 32 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo", "findingNumber"}) |
| 33 | |
| 34 | type codeQualityRule struct { |
| 35 | ID *string `json:"id,omitempty"` |
| 36 | Title *string `json:"title,omitempty"` |
| 37 | Description *string `json:"description,omitempty"` |
| 38 | Help *string `json:"help,omitempty"` |
| 39 | Severity *string `json:"severity,omitempty"` |
| 40 | Category *string `json:"category,omitempty"` |
| 41 | } |
| 42 | |
| 43 | type codeQualityLocation struct { |
| 44 | Path *string `json:"path,omitempty"` |
| 45 | StartLine *int `json:"start_line,omitempty"` |
| 46 | StartColumn *int `json:"start_column,omitempty"` |
| 47 | EndLine *int `json:"end_line,omitempty"` |
| 48 | EndColumn *int `json:"end_column,omitempty"` |
| 49 | } |
| 50 | |
| 51 | type codeQualityMessage struct { |
| 52 | Text string `json:"text"` |
| 53 | Markdown string `json:"markdown"` |
| 54 | } |
| 55 | |
| 56 | type codeQualityFinding struct { |
| 57 | Number *int `json:"number,omitempty"` |
| 58 | State *string `json:"state,omitempty"` |
| 59 | URL *string `json:"url,omitempty"` |
| 60 | Rule *codeQualityRule `json:"rule,omitempty"` |
| 61 | Location *codeQualityLocation `json:"location,omitempty"` |
| 62 | Message *codeQualityMessage `json:"message,omitempty"` |
| 63 | CreatedAt *github.Timestamp `json:"created_at,omitempty"` |
| 64 | } |
| 65 | |
| 66 | // Setup mock finding for success case |
| 67 | mockFinding := &codeQualityFinding{ |
| 68 | Number: github.Ptr(42), |
| 69 | State: github.Ptr("open"), |
| 70 | Rule: &codeQualityRule{ |
| 71 | ID: github.Ptr("test-rule"), |
| 72 | Description: github.Ptr("Test Rule Description"), |
| 73 | }, |
| 74 | } |
| 75 |
nothing calls this directly
no test coverage detected