1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-30 10:19:03 +01:00
gojekyll/pages/drops_test.go
Oliver Steele 0a0fa46ab3 Page drops use []byte instead of string
Improves perf on jekyll/docs 0.80s ± 0.06s -> 54s ± 0.05
2017-07-23 16:21:24 -04:00

35 lines
1.0 KiB
Go

package pages
import (
"testing"
"time"
"github.com/osteele/gojekyll/config"
"github.com/osteele/liquid"
"github.com/stretchr/testify/require"
)
func TestStaticFile_ToLiquid(t *testing.T) {
site := siteFake{t, config.Default()}
page, err := NewFile(site, "testdata/static.html", "static.html", map[string]interface{}{})
require.NoError(t, err)
drop := page.(liquid.Drop).ToLiquid().(map[string]interface{})
require.Equal(t, "static", drop["basename"])
require.Equal(t, "static.html", drop["name"])
require.Equal(t, "/static.html", drop["path"])
require.Equal(t, ".html", drop["extname"])
require.IsType(t, time.Now(), drop["modified_time"])
}
func TestPage_ToLiquid(t *testing.T) {
site := siteFake{t, config.Default()}
page, err := NewFile(site, "testdata/excerpt.md", "excerpt.md", map[string]interface{}{})
require.NoError(t, err)
drop := page.(liquid.Drop).ToLiquid()
excerpt := drop.(map[string]interface{})["excerpt"]
ex, ok := excerpt.([]byte)
require.True(t, ok)
require.Equal(t, "First line.", string(ex))
}