MCPcopy
hub / github.com/cheat/cheat / TestConfigYAMLErrors

Function TestConfigYAMLErrors

internal/config/config_extended_test.go:12–31  ·  view source on GitHub ↗

TestConfigYAMLErrors tests YAML parsing errors

(t *testing.T)

Source from the content-addressed store, hash-verified

10
11// TestConfigYAMLErrors tests YAML parsing errors
12func TestConfigYAMLErrors(t *testing.T) {
13 // Create a temporary file with invalid YAML
14 tempDir, err := os.MkdirTemp("", "cheat-config-test-*")
15 if err != nil {
16 t.Fatalf("failed to create temp dir: %v", err)
17 }
18 defer os.RemoveAll(tempDir)
19
20 invalidYAML := filepath.Join(tempDir, "invalid.yml")
21 err = os.WriteFile(invalidYAML, []byte("cheatpaths: [{unclosed\n"), 0644)
22 if err != nil {
23 t.Fatalf("failed to write invalid yaml: %v", err)
24 }
25
26 // Attempt to load invalid YAML
27 _, err = New(invalidYAML, false)
28 if err == nil {
29 t.Error("expected error for invalid YAML, got nil")
30 }
31}
32
33// TestConfigDefaults tests default values
34func TestConfigDefaults(t *testing.T) {

Callers

nothing calls this directly

Calls 1

NewFunction · 0.70

Tested by

no test coverage detected