Skip to content

Commit

Permalink
gp --exclusion new flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sarao1310 committed Jul 9, 2023
1 parent 44d23ac commit 002e774
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions artifactory/commands/golang/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,26 @@ func TestGetAbsolutePaths(t *testing.T) {
expectedResults := []string{filepath.Join(wd, "dir1", "*"), filepath.Join(wd, "*.txt"), filepath.Join(wd, "*", "dir2", "*")}
assert.ElementsMatch(t, result, expectedResults)
}

func TestIsPathExcluded(t *testing.T) {
testData := []struct {
excludedPathStr string
includedPaths []string
excludedPaths []string
}{
{"(^/homeDir/testdata/dir1/.*$)", []string{"homeDir/testdata/dir1/b.txt}"}, []string{"homeDir/testdata/.gitignore", "homeDir/testdata/a.txt", "homeDir/testdata/dir2/dir2.text"}},
{"(^/homeDir/testdata/dir2/.*$)|(^/homeDir/dir3/.*$)", []string{"homeDir/testdata/dir2/dir2.text", "homeDir/testdata/dir3/c.txt"}, []string{"homeDir/testdata/a.txt", "homeDir/testdata/dir1/b.txt"}},
}
for _, test := range testData {
for _, included := range test.includedPaths {
result, err := isPathExcluded(test.excludedPathStr, included)
assert.NoError(t, err)
assert.True(t, result)
}
for _, excluded := range test.excludedPaths {
result, err := isPathExcluded(test.excludedPathStr, excluded)
assert.NoError(t, err)
assert.False(t, result)
}
}
}

0 comments on commit 002e774

Please sign in to comment.