mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 03:03:32 +01:00
test: improve mutation coverage across 4 modules
Mutation testing (56 mutations, 10 modules) identified 7 surviving mutations. Added 5 targeted tests to kill all actionable survivors. Remaining 2 are logically equivalent condition reorderings in filter.go. Overall mutation score: 96.4%. New tests: - TestHasMalformedYAML: YAML unmarshal error path - TestInvalidateInvalidCheatpath: cheatpath.Validate() delegation - TestIndentTrimsWhitespace: TrimSpace behavior - TestColorizeDefaultSyntax: default "bash" lexer - TestColorizeExplicitSyntax: lexer differentiation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -93,3 +93,20 @@ To foo the bar: baz`
|
||||
t.Errorf("failed to parse text: want: %s, got: %s", markdown, text)
|
||||
}
|
||||
}
|
||||
|
||||
// TestHasMalformedYAML asserts that an error is returned when the frontmatter
|
||||
// contains invalid YAML that cannot be unmarshalled
|
||||
func TestHasMalformedYAML(t *testing.T) {
|
||||
|
||||
// stub cheatsheet content with syntactically invalid YAML between the
|
||||
// delimiters (a bare tab character followed by unquoted colon)
|
||||
markdown := "---\n\t:\t:\n---\nBody text here"
|
||||
|
||||
// parse the frontmatter
|
||||
_, _, err := parse(markdown)
|
||||
|
||||
// assert that an error was returned due to YAML unmarshal failure
|
||||
if err == nil {
|
||||
t.Error("failed to error on malformed YAML frontmatter")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user