1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-12-13 02:07:22 +01:00
gojekyll/config/config_test.go
Oliver Steele c60af75d06 Coverage
2017-07-03 13:03:45 -04:00

45 lines
1.0 KiB
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()
require.NoError(t, Unmarshal([]byte(`plugins: ['a']`), &c))
require.Equal(t, []string{"a"}, c.Plugins)
c = Default()
require.NoError(t, 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"))
}