1
0
Fork 0
mirror of https://github.com/Luzifer/wiki.git synced 2024-11-08 14:50:11 +00:00
wiki/storage_test.go

45 lines
692 B
Go
Raw Normal View History

2019-08-04 22:42:37 +00:00
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
2019-08-04 22:42:37 +00:00
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)
2019-08-04 22:42:37 +00:00
assert.Equal(t, "# Header\n\ncontent", sFile.Content)
assert.Equal(t, map[string]any{"key": "value"}, sFile.Meta)
2019-08-04 22:42:37 +00:00
// Case: No header
file = "# Header\n\ncontent"
sFile, err = storedFileFromString(file)
require.NoError(t, err)
2019-08-04 22:42:37 +00:00
assert.Equal(t, "# Header\n\ncontent", sFile.Content)
assert.Len(t, sFile.Meta, 0)
2019-08-04 22:42:37 +00:00
}