|
|
|
@ -87,6 +87,13 @@ func TestExtractFrontMatterWithValidContent(t *testing.T) {
|
|
|
|
|
"parsing empty input yields unexpected result",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fm, e = parser.ExtractFrontMatter([]string{"# Content", "..."})
|
|
|
|
|
asrt.EqualValues(
|
|
|
|
|
extractResult{map[string]string{}, nil},
|
|
|
|
|
extractResult{fm, e},
|
|
|
|
|
"parsing empty input yields unexpected result",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fm, e = parser.ExtractFrontMatter([]string{"Key: Value", "---"})
|
|
|
|
|
asrt.EqualValues(
|
|
|
|
|
extractResult{map[string]string{"Key": "Value"}, nil},
|
|
|
|
@ -133,11 +140,11 @@ func TestExtractFrontMatterWithBadKeys(t *testing.T) {
|
|
|
|
|
"parsing invalid FrontMatter with blank key yields invalid result",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fm, e = parser.ExtractFrontMatter([]string{"Key: Value", "Key: Dupe Value"})
|
|
|
|
|
fm, e = parser.ExtractFrontMatter([]string{"Key: Value", "Key: Dupe Value", "---"})
|
|
|
|
|
asrt.EqualValues(
|
|
|
|
|
extractResult{map[string]string{"Key": "Value"}, fmt.Errorf("error on parsing line 2: %w", parser.ErrDuplicateKey)},
|
|
|
|
|
extractResult{fm, e},
|
|
|
|
|
"parsing invalid FrontMatter with no final dashes yields invalid result",
|
|
|
|
|
"parsing invalid FrontMatter with duplicate key entry yields invalid result",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fm, e = parser.ExtractFrontMatter([]string{"Key: Value", "Another Key: Another Value"})
|
|
|
|
|