TestHasMalformedYAML asserts that an error is returned when the frontmatter contains invalid YAML that cannot be unmarshalled
(t *testing.T)
| 97 | // TestHasMalformedYAML asserts that an error is returned when the frontmatter |
| 98 | // contains invalid YAML that cannot be unmarshalled |
| 99 | func TestHasMalformedYAML(t *testing.T) { |
| 100 | |
| 101 | // stub cheatsheet content with syntactically invalid YAML between the |
| 102 | // delimiters (a bare tab character followed by unquoted colon) |
| 103 | markdown := "---\n\t:\t:\n---\nBody text here" |
| 104 | |
| 105 | // parse the frontmatter |
| 106 | _, _, err := parse(markdown) |
| 107 | |
| 108 | // assert that an error was returned due to YAML unmarshal failure |
| 109 | if err == nil { |
| 110 | t.Error("failed to error on malformed YAML frontmatter") |
| 111 | } |
| 112 | } |