From 172155654d2930562ba61ffffaf33a815c3c0607 Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Mon, 27 Mar 2023 23:03:23 -0700 Subject: [PATCH] File name compare (#2956) Check the file name recorded in the ItemInfo (and used during restore) matches the expected file name for the item. We can't directly compare file names because files are now stored by ID in kopia. --- #### 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: Supportability/Tests - [ ] :computer: CI/Deployment - [x] :broom: Tech Debt/Cleanup #### Issue(s) * #2897 #### Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .../connector/graph_connector_helper_test.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/internal/connector/graph_connector_helper_test.go b/src/internal/connector/graph_connector_helper_test.go index 8b7680083..54e7c7b5a 100644 --- a/src/internal/connector/graph_connector_helper_test.go +++ b/src/internal/connector/graph_connector_helper_test.go @@ -740,9 +740,12 @@ func compareOneDriveItem( return true } - name := item.UUID() - isMeta := strings.HasSuffix(name, onedrive.MetaFileSuffix) || - strings.HasSuffix(name, onedrive.DirMetaFileSuffix) + var ( + displayName string + name = item.UUID() + isMeta = strings.HasSuffix(name, onedrive.MetaFileSuffix) || + strings.HasSuffix(name, onedrive.DirMetaFileSuffix) + ) if isMeta { var itemType *onedrive.MetadataItem @@ -755,8 +758,12 @@ func compareOneDriveItem( // Don't need to check SharePoint because it was added after we stopped // adding meta files to backup details. if info.OneDrive != nil { + displayName = oitem.Info().OneDrive.ItemName + assert.False(t, oitem.Info().OneDrive.IsMeta, "meta marker for non meta item %s", name) - } else if info.SharePoint == nil { + } else if info.SharePoint != nil { + displayName = oitem.Info().SharePoint.ItemName + } else { assert.Fail(t, "ItemInfo is not SharePoint or OneDrive") } } @@ -842,6 +849,10 @@ func compareOneDriveItem( // Compare against the version with the file name embedded because that's what // the auto-generated expected data has. assert.Equal(t, expectedData, buf) + // Display name in ItemInfo should match the name the file was given in the + // test. Name used for the lookup key has a `.data` suffix to make it unique + // from the metadata files' lookup keys. + assert.Equal(t, fileData.FileName, displayName+onedrive.DataFileSuffix) return true }