(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func TestJSONFormatter_NoIssues(t *testing.T) { |
| 61 | linter := newDefaultLinter(t) |
| 62 | result, err := linter.ParseAndLint("feat: valid commit message") |
| 63 | if err != nil { |
| 64 | t.Fatal(err) |
| 65 | } |
| 66 | f := &formatter.JSONFormatter{} |
| 67 | out, fErr := f.Format(result) |
| 68 | if fErr != nil { |
| 69 | t.Fatal(fErr) |
| 70 | } |
| 71 | var parsed map[string]interface{} |
| 72 | if jErr := json.Unmarshal([]byte(out), &parsed); jErr != nil { |
| 73 | t.Fatalf("invalid JSON output: %v", jErr) |
| 74 | } |
| 75 | issues, ok := parsed["issues"].([]interface{}) |
| 76 | if !ok { |
| 77 | t.Fatal("expected 'issues' array in JSON output") |
| 78 | } |
| 79 | if len(issues) != 0 { |
| 80 | t.Errorf("expected 0 issues, got %d", len(issues)) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func TestJSONFormatter_WithIssues(t *testing.T) { |
| 85 | linter := newDefaultLinter(t) |
nothing calls this directly
no test coverage detected