1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 00:14:39 +01:00
gojekyll/site/site_test.go
2017-08-24 12:25:38 -04:00

47 lines
1.4 KiB
Go

package site
import (
"testing"
"github.com/osteele/gojekyll/config"
"github.com/stretchr/testify/require"
)
func TestKeepFile(t *testing.T) {
s := New(config.Flags{})
require.Equal(t, "", s.PathPrefix())
require.False(t, s.KeepFile("random"))
require.True(t, s.KeepFile(".git"))
require.True(t, s.KeepFile(".svn"))
}
func TestExclude(t *testing.T) {
s := New(config.Flags{})
s.cfg.Exclude = append(s.cfg.Exclude, "exclude/")
s.cfg.Include = append(s.cfg.Include, ".include/")
require.False(t, s.Exclude("."))
require.True(t, s.Exclude(".git"))
require.True(t, s.Exclude(".dir"))
require.True(t, s.Exclude(".dir/file"))
require.False(t, s.Exclude(".htaccess"))
require.False(t, s.Exclude("dir"))
require.False(t, s.Exclude("dir/file"))
require.True(t, s.Exclude("dir/.file"))
require.True(t, s.Exclude("dir/#file"))
require.True(t, s.Exclude("dir/~file"))
require.True(t, s.Exclude("dir/file~"))
require.True(t, s.Exclude("dir/subdir/.file"))
require.False(t, s.Exclude(".include/file"))
require.True(t, s.Exclude("exclude/file"))
require.False(t, s.Exclude("_posts"))
require.False(t, s.Exclude("_posts/file"))
require.True(t, s.Exclude("_posts/_file"))
require.True(t, s.Exclude("_posts/_dir/file"))
// The following aren't documented but are evident
// TODO submit a doc PR to Jekyll
require.True(t, s.Exclude("#file"))
require.True(t, s.Exclude("~file"))
require.True(t, s.Exclude("file~"))
}