2016-05-31 16:38:47 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-11-15 17:01:18 +00:00
|
|
|
"github.com/git-lfs/git-lfs/config"
|
2016-05-31 16:38:47 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-08-03 23:42:21 +00:00
|
|
|
testcfg = config.NewFrom(config.Values{
|
2017-04-12 21:29:11 +00:00
|
|
|
Git: map[string][]string{
|
|
|
|
"lfs.fetchinclude": []string{"/default/include"},
|
|
|
|
"lfs.fetchexclude": []string{"/default/exclude"},
|
2016-08-03 23:42:21 +00:00
|
|
|
},
|
2016-05-31 16:38:47 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDetermineIncludeExcludePathsReturnsCleanedPaths(t *testing.T) {
|
2016-08-01 22:47:41 +00:00
|
|
|
inc := "/some/include"
|
|
|
|
exc := "/some/exclude"
|
|
|
|
i, e := determineIncludeExcludePaths(testcfg, &inc, &exc)
|
2016-05-31 16:38:47 +00:00
|
|
|
|
|
|
|
assert.Equal(t, []string{"/some/include"}, i)
|
|
|
|
assert.Equal(t, []string{"/some/exclude"}, e)
|
|
|
|
}
|
|
|
|
|
2016-08-01 22:47:41 +00:00
|
|
|
func TestDetermineIncludeExcludePathsReturnsEmptyPaths(t *testing.T) {
|
|
|
|
inc := ""
|
|
|
|
exc := ""
|
|
|
|
i, e := determineIncludeExcludePaths(testcfg, &inc, &exc)
|
|
|
|
|
|
|
|
assert.Empty(t, i)
|
|
|
|
assert.Empty(t, e)
|
|
|
|
}
|
|
|
|
|
2016-05-31 16:38:47 +00:00
|
|
|
func TestDetermineIncludeExcludePathsReturnsDefaultsWhenAbsent(t *testing.T) {
|
2016-08-01 22:47:41 +00:00
|
|
|
i, e := determineIncludeExcludePaths(testcfg, nil, nil)
|
2016-05-31 16:38:47 +00:00
|
|
|
|
|
|
|
assert.Equal(t, []string{"/default/include"}, i)
|
|
|
|
assert.Equal(t, []string{"/default/exclude"}, e)
|
|
|
|
}
|