Skip to content

Commit

Permalink
TestNothingToTransferWithoutEmptyDirs
Browse files Browse the repository at this point in the history
  • Loading branch information
nielash committed Apr 6, 2024
1 parent 13c72a9 commit 16d856a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fs/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2635,7 +2635,7 @@ func TestSyncConcurrentTruncate(t *testing.T) {

// Tests that nothing is transferred when src and dst already match
// Run the same sync twice, ensure no action is taken the second time
func TestNothingToTransfer(t *testing.T) {
func testNothingToTransfer(t *testing.T, copyEmptySrcDirs bool) {
accounting.GlobalStats().ResetCounters()
ctx, _ := fs.AddConfig(context.Background())
r := fstest.NewRun(t)
Expand All @@ -2660,7 +2660,7 @@ func TestNothingToTransfer(t *testing.T) {
accounting.GlobalStats().ResetCounters()
ctx = predictDstFromLogger(ctx)
output := bilib.CaptureOutput(func() {
err = CopyDir(ctx, r.Fremote, r.Flocal, true)
err = CopyDir(ctx, r.Fremote, r.Flocal, copyEmptySrcDirs)
require.NoError(t, err)
})
require.NotNil(t, output)
Expand All @@ -2682,7 +2682,7 @@ func TestNothingToTransfer(t *testing.T) {
accounting.GlobalStats().ResetCounters()
ctx = predictDstFromLogger(ctx)
output = bilib.CaptureOutput(func() {
err = CopyDir(ctx, r.Fremote, r.Flocal, true)
err = CopyDir(ctx, r.Fremote, r.Flocal, copyEmptySrcDirs)
require.NoError(t, err)
})
require.NotNil(t, output)
Expand All @@ -2701,6 +2701,14 @@ func TestNothingToTransfer(t *testing.T) {
assert.Equal(t, int64(0), accounting.GlobalStats().GetTransfers())
}

func TestNothingToTransferWithEmptyDirs(t *testing.T) {
testNothingToTransfer(t, true)
}

func TestNothingToTransferWithoutEmptyDirs(t *testing.T) {
testNothingToTransfer(t, false)
}

// for testing logger:
func predictDstFromLogger(ctx context.Context) context.Context {
opt := operations.NewLoggerOpt()
Expand Down

0 comments on commit 16d856a

Please sign in to comment.