MCPcopy
hub / github.com/cheat/cheat / TestHasNoFrontmatter

Function TestHasNoFrontmatter

internal/sheet/parse_test.go:47–71  ·  view source on GitHub ↗

TestHasFrontmatter asserts that markdown is properly parsed when it does not contain frontmatter

(t *testing.T)

Source from the content-addressed store, hash-verified

45// TestHasFrontmatter asserts that markdown is properly parsed when it does not
46// contain frontmatter
47func TestHasNoFrontmatter(t *testing.T) {
48
49 // stub our cheatsheet content
50 markdown := "To foo the bar: baz"
51
52 // parse the frontmatter
53 fm, text, err := parse(markdown)
54
55 // assert expectations
56 if err != nil {
57 t.Errorf("failed to parse markdown: %v", err)
58 }
59
60 if text != markdown {
61 t.Errorf("failed to parse text: want: %s, got: %s", markdown, text)
62 }
63
64 if fm.Syntax != "" {
65 t.Errorf("failed to parse syntax: want: '', got: %s", fm.Syntax)
66 }
67
68 if len(fm.Tags) != 0 {
69 t.Errorf("failed to parse tags: want: len 0, got: len %d", len(fm.Tags))
70 }
71}
72
73// TestHasInvalidFrontmatter asserts that markdown is properly parsed when it
74// contains invalid frontmatter

Callers

nothing calls this directly

Calls 1

parseFunction · 0.85

Tested by

no test coverage detected