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:
@@ -157,3 +157,28 @@ func TestInvalidateDuplicateCheatpathPaths(t *testing.T) {
|
||||
t.Errorf("failed to invalidate config with cheatpaths with duplicate paths")
|
||||
}
|
||||
}
|
||||
|
||||
// TestInvalidateInvalidCheatpath asserts that configs containing a cheatpath
|
||||
// with an empty name are invalidated
|
||||
func TestInvalidateInvalidCheatpath(t *testing.T) {
|
||||
|
||||
// mock a config with a cheatpath that has an empty name
|
||||
conf := Config{
|
||||
Colorize: true,
|
||||
Editor: "vim",
|
||||
Formatter: "terminal16m",
|
||||
Cheatpaths: []cheatpath.Path{
|
||||
cheatpath.Path{
|
||||
Name: "",
|
||||
Path: "/foo",
|
||||
ReadOnly: false,
|
||||
Tags: []string{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// assert that an error is returned
|
||||
if err := conf.Validate(); err == nil {
|
||||
t.Errorf("failed to invalidate config with invalid cheatpath (empty name)")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user