fix(unit_test): frontmatter parse test

This commit is contained in:
Kristian Borgwarth 2026-04-06 23:09:52 +02:00
parent a2a6c2743c
commit d4c922ba53
2 changed files with 35 additions and 2 deletions

View file

@ -2,8 +2,8 @@
test: test-unit test-integration
#test-unit:
#go test ./test/test_unit/...
test-unit:
go test ./test/test_unit/...
test-integration:
go test ./test/test_integration/...

View file

@ -0,0 +1,33 @@
package filehandling
import (
"testing"
filehandling "github.com/KristianJBorgwarth/dendrite.daemon/core/file_handling"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestParseTags_ValidFrontMatter_ReturnsTags(t *testing.T) {
input := `---
title: My Note
tags: ["test", "note"]
---
This is the content of the note.`
result, err := filehandling.ParseFrontMatter([]byte(input))
require.NoError(t, err)
assert.Equal(t, "My Note", result.Title)
assert.Equal(t, []string{"test", "note"}, result.Tags)
}
func TestParseTags_MissingDelimiter_ReturnsError(t *testing.T) {
input := `title: My Note
tags: ["test", "note"]
This is the content of the note.`
_, err := filehandling.ParseFrontMatter([]byte(input))
assert.ErrorContains(t, err, "missing front matter delimiter")
}