Documentation
¶
Overview ¶
Package rulestest provides test helpers for validating Telescope rules. It works with both built-in Go rules and SDK plugin rules.
Usage:
func TestMyRule(t *testing.T) {
rulestest.Run(t, "my-rule-id", rulestest.Case{
Name: "catches missing field",
Spec: `openapi: "3.1.0"
info:
title: Test
version: "1.0"`,
Expect: []rulestest.Diag{
{Line: 1, Code: "my-rule-id", Severity: rulestest.Warn},
},
})
}
Index ¶
Constants ¶
View Source
const ( Error = ctypes.SeverityError Warn = ctypes.SeverityWarning Info = ctypes.SeverityInfo Hint = ctypes.SeverityHint )
Severity constants for test expectations.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(t *testing.T, analyzer treesitter.Analyzer, cases ...Case)
Run executes a rule's analyzer against the given test cases. The analyzer should be obtained from rules.Define(...).Build().
Types ¶
Click to show internal directories.
Click to hide internal directories.