From b2c9ef23fae6de90526f3d33413c9ddb768070ce Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 31 Mar 2020 10:58:49 +0100 Subject: [PATCH] sync: make --track-renames tests only check rename count if expecting renames --- fs/sync/sync_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/sync/sync_test.go b/fs/sync/sync_test.go index 94994f64f..ceb9f5dfc 100644 --- a/fs/sync/sync_test.go +++ b/fs/sync/sync_test.go @@ -1067,9 +1067,11 @@ func TestSyncWithTrackRenames(t *testing.T) { fstest.CheckItems(t, r.Fremote, f1, f2) - // Check we renamed something - renames := accounting.GlobalStats().Renames(0) - assert.Equal(t, canTrackRenames, renames != 0, fmt.Sprintf("canTrackRenames=%v, renames=%d", canTrackRenames, renames)) + // Check we renamed something if we should have + if canTrackRenames { + renames := accounting.GlobalStats().Renames(0) + assert.Equal(t, canTrackRenames, renames != 0, fmt.Sprintf("canTrackRenames=%v, renames=%d", canTrackRenames, renames)) + } } func TestParseRenamesStrategyModtime(t *testing.T) { @@ -1136,9 +1138,11 @@ func TestSyncWithTrackRenamesStrategyModtime(t *testing.T) { fstest.CheckItems(t, r.Fremote, f1, f2) - // Check we renamed something - renames := accounting.GlobalStats().Renames(0) - assert.Equal(t, canTrackRenames, renames != 0, fmt.Sprintf("canTrackRenames=%v, renames=%d", canTrackRenames, renames)) + // Check we renamed something if we should have + if canTrackRenames { + renames := accounting.GlobalStats().Renames(0) + assert.Equal(t, canTrackRenames, renames != 0, fmt.Sprintf("canTrackRenames=%v, renames=%d", canTrackRenames, renames)) + } } func toyFileTransfers(r *fstest.Run) int64 {