2017-07-04 15:09:36 +02:00
|
|
|
package site
|
2017-06-15 13:19:49 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-01-29 20:17:23 +01:00
|
|
|
"github.com/danog/gojekyll/config"
|
2017-06-16 22:47:49 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2017-06-15 13:19:49 +02:00
|
|
|
)
|
|
|
|
|
2017-07-28 00:07:42 +02:00
|
|
|
func TestKeepFile(t *testing.T) {
|
2017-07-04 15:09:36 +02:00
|
|
|
s := New(config.Flags{})
|
2017-06-24 19:30:01 +02:00
|
|
|
require.Equal(t, "", s.PathPrefix())
|
|
|
|
require.False(t, s.KeepFile("random"))
|
2017-07-02 01:42:48 +02:00
|
|
|
require.True(t, s.KeepFile(".git"))
|
|
|
|
require.True(t, s.KeepFile(".svn"))
|
2017-06-15 13:19:49 +02:00
|
|
|
}
|
2017-07-28 00:07:42 +02:00
|
|
|
|
|
|
|
func TestExclude(t *testing.T) {
|
|
|
|
s := New(config.Flags{})
|
2017-08-24 18:25:38 +02:00
|
|
|
s.cfg.Exclude = append(s.cfg.Exclude, "exclude/")
|
|
|
|
s.cfg.Include = append(s.cfg.Include, ".include/")
|
2017-07-28 00:07:42 +02:00
|
|
|
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~"))
|
|
|
|
}
|