Skip to content

Commit

Permalink
command/cp: update --include test
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmethakanbesel committed Jul 24, 2023
1 parent 0819eab commit ab97b40
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions e2e/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4269,7 +4269,7 @@ func TestCopyS3ObjectsWithIncludeExcludeFilter(t *testing.T) {
assert.Assert(t, fs.Equal(cmd.Dir, expected))
}

// cp --exclude "file*" --include "*.py" s3://bucket/* .
// cp --exclude "file*" --exclude "vendor/*" --include "*.py" --include "*.go" s3://bucket/* .
func TestCopyS3ObjectsWithIncludeExcludeFilter2(t *testing.T) {
t.Parallel()

Expand All @@ -4279,16 +4279,22 @@ func TestCopyS3ObjectsWithIncludeExcludeFilter2(t *testing.T) {
createBucket(t, s3client, bucket)

const (
includePattern = "*.py"
excludePattern = "file*"
fileContent = "content"
includePattern = "*.py"
includePattern2 = "*.go"
excludePattern = "file*"
excludePattern2 = "vendor/*"
fileContent = "content"
)

files := [...]string{
"file1.py",
"file2.py",
"file1.go",
"file2.go",
"test.py",
"app.py",
"app.go",
"vendor/package.go",
"docs/readme.md",
}

Expand All @@ -4298,14 +4304,15 @@ func TestCopyS3ObjectsWithIncludeExcludeFilter2(t *testing.T) {

srcpath := fmt.Sprintf("s3://%s", bucket)

cmd := s5cmd("cp", "--exclude", excludePattern, "--include", includePattern, srcpath+"/*", ".")
cmd := s5cmd("cp", "--exclude", excludePattern, "--exclude", excludePattern2, "--include", includePattern, "--include", includePattern2, srcpath+"/*", ".")
result := icmd.RunCmd(cmd)

result.Assert(t, icmd.Success)

assertLines(t, result.Stdout(), map[int]compareFunc{
0: equals("cp %v/app.py %s", srcpath, files[3]),
1: equals("cp %v/test.py %s", srcpath, files[2]),
0: equals("cp %v/app.go %s", srcpath, files[6]),
1: equals("cp %v/app.py %s", srcpath, files[5]),
2: equals("cp %v/test.py %s", srcpath, files[4]),
}, sortInput(true))

// assert s3
Expand All @@ -4316,6 +4323,7 @@ func TestCopyS3ObjectsWithIncludeExcludeFilter2(t *testing.T) {
expectedFileSystem := []fs.PathOp{
fs.WithFile("test.py", fileContent),
fs.WithFile("app.py", fileContent),
fs.WithFile("app.go", fileContent),
}
// assert local filesystem
expected := fs.Expected(t, expectedFileSystem...)
Expand Down

0 comments on commit ab97b40

Please sign in to comment.