Fix DownloadAndSyncDelete test
A bug was found that prevent the test assertion when non desired files
was found in the sync dir.
@@ -740,7 +740,7 @@ func TestArtifactoryDownloadAndSyncDeletes(t *testing.T) {
// Download repo1/syncDir/ to out/, exclude the pattern "*c*.in" and sync out/
artifactoryCli.Exec("download", tests.RtRepo1+"/syncDir/", outDirPath, "--sync-deletes="+outDirPath+"syncDir"+string(os.PathSeparator), "--exclude-patterns=syncDir/testdata/*c*in")
- paths, err = fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
+ paths, err = fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out+string(os.PathSeparator)+"syncDir"+string(os.PathSeparator), false)
assert.NoError(t, err)
checkSyncedDirContent(tests.GetSyncExpectedDeletesDownloadStep5(), paths, t)
@@ -758,7 +758,7 @@ func TestArtifactoryDownloadAndSyncDeletes(t *testing.T) {
// Download repo1/syncDir/ to out/ and sync out/
artifactoryCli.Exec("download", tests.RtRepo1+"/syncDir/", outDirPath, "--sync-deletes="+outDirPath+"syncDir"+string(os.PathSeparator))
- paths, err = fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
+ paths, err = fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out+string(os.PathSeparator)+"syncDir"+string(os.PathSeparator), false)
assert.NoError(t, err)
checkSyncedDirContent(tests.GetSyncExpectedDeletesDownloadStep7(), paths, t)
@@ -780,12 +780,13 @@ func checkSyncedDirContent(expected, actual []string, t *testing.T) {
// Check if the path equals to an existing file (for a file) OR
// if the path is a prefix of some path of an existing file (for a dir).
func isExclusivelyExistLocally(expected, actual []string) error {
+ expectedLastIndex := len(expected) - 1
for _, v := range actual {
for i, r := range expected {
if strings.HasPrefix(r, v) || v == r {
break
}
- if i == len(actual)-1 {
+ if i == expectedLastIndex {
return errors.New("Should not have : " + v)
}
}
