From efe1b6292df61969c8900419368cf7d9ba4215b7 Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Wed, 15 Feb 2023 13:14:32 -0800 Subject: [PATCH] Extra test for some recursive delete behavior (#2478) ## Description Folders replaced after a delete should not have their subfolders reparented to the new folder. ## Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No ## Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [x] :robot: Test - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup ## Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- src/internal/kopia/upload_test.go | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/internal/kopia/upload_test.go b/src/internal/kopia/upload_test.go index 3a27834d0..6ceb43cca 100644 --- a/src/internal/kopia/upload_test.go +++ b/src/internal/kopia/upload_test.go @@ -1739,6 +1739,40 @@ func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTreeMultipleSubdirecto }, ), }, + { + name: "ReplaceDeletedSubtreeWithNew", + inputCollections: func(t *testing.T) []data.BackupCollection { + oldInbox := mockconnector.NewMockExchangeCollection(inboxStorePath, inboxLocPath, 0) + oldInbox.PrevPath = inboxStorePath + oldInbox.ColState = data.DeletedState + + newCol := mockconnector.NewMockExchangeCollection(inboxStorePath, inboxLocPath, 1) + newCol.ColState = data.NewState + newCol.Names[0] = workFileName2 + newCol.Data[0] = workFileData2 + + return []data.BackupCollection{oldInbox, newCol} + }, + expected: expectedTreeWithChildren( + []string{ + testTenant, + service, + testUser, + category, + }, + []*expectedNode{ + { + name: testInboxID, + children: []*expectedNode{ + { + name: workFileName2, + data: workFileData2, + }, + }, + }, + }, + ), + }, { name: "ReplaceMovedDirectory", inputCollections: func(t *testing.T) []data.BackupCollection {