github.com/git-lfs/git-lfs@v2.5.2+incompatible/commands/commands_test.go (about)

     1  package commands
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/git-lfs/git-lfs/config"
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  var (
    11  	testcfg = config.NewFrom(config.Values{
    12  		Git: map[string][]string{
    13  			"lfs.fetchinclude": []string{"/default/include"},
    14  			"lfs.fetchexclude": []string{"/default/exclude"},
    15  		},
    16  	})
    17  )
    18  
    19  func TestDetermineIncludeExcludePathsReturnsCleanedPaths(t *testing.T) {
    20  	inc := "/some/include"
    21  	exc := "/some/exclude"
    22  	i, e := determineIncludeExcludePaths(testcfg, &inc, &exc)
    23  
    24  	assert.Equal(t, []string{"/some/include"}, i)
    25  	assert.Equal(t, []string{"/some/exclude"}, e)
    26  }
    27  
    28  func TestDetermineIncludeExcludePathsReturnsEmptyPaths(t *testing.T) {
    29  	inc := ""
    30  	exc := ""
    31  	i, e := determineIncludeExcludePaths(testcfg, &inc, &exc)
    32  
    33  	assert.Empty(t, i)
    34  	assert.Empty(t, e)
    35  }
    36  
    37  func TestDetermineIncludeExcludePathsReturnsDefaultsWhenAbsent(t *testing.T) {
    38  	i, e := determineIncludeExcludePaths(testcfg, nil, nil)
    39  
    40  	assert.Equal(t, []string{"/default/include"}, i)
    41  	assert.Equal(t, []string{"/default/exclude"}, e)
    42  }