TestHasInvalidFrontmatter asserts that markdown is properly parsed when it contains invalid frontmatter
(t *testing.T)
| 73 | // TestHasInvalidFrontmatter asserts that markdown is properly parsed when it |
| 74 | // contains invalid frontmatter |
| 75 | func TestHasInvalidFrontmatter(t *testing.T) { |
| 76 | |
| 77 | // stub our cheatsheet content (with invalid frontmatter) |
| 78 | markdown := `--- |
| 79 | syntax: go |
| 80 | tags: [ test ] |
| 81 | To foo the bar: baz` |
| 82 | |
| 83 | // parse the frontmatter |
| 84 | _, text, err := parse(markdown) |
| 85 | |
| 86 | // assert that an error was returned |
| 87 | if err == nil { |
| 88 | t.Error("failed to error on invalid frontmatter") |
| 89 | } |
| 90 | |
| 91 | // assert that the "raw" markdown was returned |
| 92 | if text != markdown { |
| 93 | t.Errorf("failed to parse text: want: %s, got: %s", markdown, text) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // TestHasMalformedYAML asserts that an error is returned when the frontmatter |
| 98 | // contains invalid YAML that cannot be unmarshalled |