1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-12-02 16:47:50 +01:00
gojekyll/config/config_test.go
Oliver Steele 18c715c2be Coverage
2017-07-03 11:48:06 -04:00

45 lines
1001 B
Go

package config
import (
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestSourceDir(t *testing.T) {
c := Default()
require.True(t, strings.HasPrefix(c.SourceDir(), "/"))
}
func TestDefaultConfig(t *testing.T) {
c := Default()
require.Equal(t, ".", c.Source)
require.Equal(t, "./_site", c.Destination)
require.Equal(t, "_layouts", c.LayoutsDir)
}
func TestPlugins(t *testing.T) {
c := Default()
Unmarshal([]byte(`plugins: ['a']`), &c)
require.Equal(t, []string{"a"}, c.Plugins)
c = Default()
Unmarshal([]byte(`gems: ['a']`), &c)
require.Equal(t, []string{"a"}, c.Plugins)
}
func TestUnmarshal(t *testing.T) {
c := Default()
err := Unmarshal([]byte(`source: x`), &c)
require.NoError(t, err)
require.Equal(t, "x", c.Source)
require.Equal(t, "./_site", c.Destination)
}
func TestIsMarkdown(t *testing.T) {
c := Default()
require.True(t, c.IsMarkdown("name.md"))
require.True(t, c.IsMarkdown("name.markdown"))
require.False(t, c.IsMarkdown("name.html"))
}