From 56cd045bff4e093c3aab3ee493c1e85fd01c2a5a Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Fri, 17 Mar 2023 20:01:40 -0700 Subject: [PATCH] Add a test with duplicate item IDs for OneDrive (#2845) Ensure that as long as drive IDs are unique we can handle items with the same ID if they're in different drives. This is a direct result of observing SharePoint sites that have multiple drives and the root of each drive has the same ID --- #### 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 #### Issue(s) * #2732 #### Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- .../connector/onedrive/collections_test.go | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/internal/connector/onedrive/collections_test.go b/src/internal/connector/onedrive/collections_test.go index 44aadebc0..6ded474fd 100644 --- a/src/internal/connector/onedrive/collections_test.go +++ b/src/internal/connector/onedrive/collections_test.go @@ -1587,6 +1587,64 @@ func (suite *OneDriveCollectionsUnitSuite) TestGet() { rootFolderPath2: getDelList("file2"), }, }, + { + name: "TwoDrives_DuplicateIDs_OneItemPageEach_NoErrors", + drives: []models.Driveable{ + drive1, + drive2, + }, + items: map[string][]deltaPagerResult{ + driveID1: { + { + items: []models.DriveItemable{ + driveRootItem("root"), + driveItem("folder", "folder", driveBasePath1, "root", false, true, false), + driveItem("file", "file", driveBasePath1+"/folder", "folder", true, false, false), + }, + deltaLink: &delta, + }, + }, + driveID2: { + { + items: []models.DriveItemable{ + driveRootItem("root"), + driveItem("folder", "folder", driveBasePath2, "root", false, true, false), + driveItem("file2", "file", driveBasePath2+"/folder", "folder", true, false, false), + }, + deltaLink: &delta2, + }, + }, + }, + errCheck: assert.NoError, + prevFolderPaths: map[string]map[string]string{ + driveID1: {}, + driveID2: {}, + }, + expectedCollections: map[string]map[data.CollectionState][]string{ + rootFolderPath1: {data.NewState: {}}, + folderPath1: {data.NewState: {"folder", "file"}}, + rootFolderPath2: {data.NewState: {}}, + folderPath2: {data.NewState: {"folder", "file2"}}, + }, + expectedDeltaURLs: map[string]string{ + driveID1: delta, + driveID2: delta2, + }, + expectedFolderPaths: map[string]map[string]string{ + driveID1: { + "root": rootFolderPath1, + "folder": folderPath1, + }, + driveID2: { + "root": rootFolderPath2, + "folder": folderPath2, + }, + }, + expectedDelList: map[string]map[string]struct{}{ + rootFolderPath1: getDelList("file"), + rootFolderPath2: getDelList("file2"), + }, + }, { name: "OneDrive_OneItemPage_Errors", drives: []models.Driveable{drive1},