Skip to content

Commit

Permalink
command/sync,e2e: add sync remote to empty local with delete test
Browse files Browse the repository at this point in the history
  • Loading branch information
seruman committed Jun 23, 2023
1 parent df37eab commit 055f887
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions e2e/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,54 @@ func TestSyncS3BucketToLocalWithDelete(t *testing.T) {
}
}

// sync --delete s3://bucket/* .
func TestSyncS3BucketToEmptyLocalWithDelete(t *testing.T) {
t.Parallel()
s3client, s5cmd := setup(t)

bucket := s3BucketFromTestName(t)
createBucket(t, s3client, bucket)

S3Content := map[string]string{
"contributing.md": "S: this is a readme file",
}

for filename, content := range S3Content {
putFile(t, s3client, bucket, filename, content)
}

workdir := fs.NewDir(t, "somedir")
defer workdir.Remove()

src := fmt.Sprintf("s3://%v/", bucket)
dst := fmt.Sprintf("%v/", workdir.Path())
dst = filepath.ToSlash(dst)

cmd := s5cmd("sync", "--delete", src+"*", dst)
result := icmd.RunCmd(cmd)

result.Assert(t, icmd.Success)
stdout := result.Stdout()
assertLines(t, stdout, map[int]compareFunc{
0: equals(`cp %vcontributing.md %vcontributing.md`, src, dst),
}, sortInput(true))

fmt.Println("stdout", "--", stdout, "--")

expectedFolderLayout := []fs.PathOp{
fs.WithFile("contributing.md", "S: this is a readme file"),
}

// assert local filesystem
expected := fs.Expected(t, expectedFolderLayout...)
assert.Assert(t, fs.Equal(workdir.Path(), expected))

// assert s3
for key, content := range S3Content {
assert.Assert(t, ensureS3Object(s3client, bucket, key, content))
}
}

// sync --delete folder/ s3://bucket/*
func TestSyncLocalToS3BucketWithDelete(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit 055f887

Please sign in to comment.