1
0
Fork 0
mirror of https://github.com/Luzifer/wiki.git synced 2024-11-09 15:20:07 +00:00
wiki/storage_test.go
Knut Ahlers e1039e5ae2
Update dependencies, modernize code
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-01-29 23:56:17 +01:00

44 lines
692 B
Go

package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestStoredFileParse(t *testing.T) {
var (
err error
file string
sFile *storedFile
)
// Case: Proper file with header
file = `
---
key: value
---
# Header
content
`
sFile, err = storedFileFromString(file)
require.NoError(t, err)
assert.Equal(t, "# Header\n\ncontent", sFile.Content)
assert.Equal(t, map[string]any{"key": "value"}, sFile.Meta)
// Case: No header
file = "# Header\n\ncontent"
sFile, err = storedFileFromString(file)
require.NoError(t, err)
assert.Equal(t, "# Header\n\ncontent", sFile.Content)
assert.Len(t, sFile.Meta, 0)
}