(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestRulesLoader_GlobalRules(t *testing.T) { |
| 11 | globalDir := t.TempDir() |
| 12 | rulesDir := filepath.Join(globalDir, "rules") |
| 13 | _ = os.MkdirAll(rulesDir, 0o755) |
| 14 | |
| 15 | // Create a global rule (no paths = applies everywhere) |
| 16 | _ = os.WriteFile(filepath.Join(rulesDir, "style.md"), []byte("Always use snake_case for Go variables."), 0o644) |
| 17 | |
| 18 | rl := NewRulesLoader(t.TempDir(), globalDir, testLogger()) |
| 19 | result := rl.LoadMatchingRules(nil) |
| 20 | |
| 21 | if !strings.Contains(result, "snake_case") { |
| 22 | t.Errorf("expected global rule content, got %q", result) |
| 23 | } |
| 24 | if !strings.Contains(result, "style") { |
| 25 | t.Errorf("expected rule name 'style' in output, got %q", result) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | func TestRulesLoader_PathSpecificRule(t *testing.T) { |
| 30 | wsDir := t.TempDir() |
nothing calls this directly
no test coverage detected