consts for drives, root: (#3385)
#### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
caea3ab6da
commit
6c410c298c
@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/connector/onedrive/metadata"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
@ -109,7 +110,6 @@ var (
|
||||
folderAName = "folder-a"
|
||||
folderBName = "b"
|
||||
folderNamedFolder = "folder"
|
||||
rootFolder = "root:"
|
||||
|
||||
fileAData = []byte(strings.Repeat("a", 33))
|
||||
fileBData = []byte(strings.Repeat("b", 65))
|
||||
@ -255,7 +255,7 @@ func (c *onedriveCollection) withPermissions(perm permData) *onedriveCollection
|
||||
metaName = ""
|
||||
}
|
||||
|
||||
if name == rootFolder {
|
||||
if name == odConsts.RootPathDir {
|
||||
return c
|
||||
}
|
||||
|
||||
@ -631,35 +631,35 @@ func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
|
||||
suite.BackupResourceOwner())
|
||||
|
||||
rootPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
}
|
||||
folderAPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
}
|
||||
subfolderBPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
folderBName,
|
||||
}
|
||||
subfolderAPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
folderBName,
|
||||
folderAName,
|
||||
}
|
||||
folderBPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderBName,
|
||||
}
|
||||
|
||||
@ -776,34 +776,34 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
folderCName := "folder-c"
|
||||
|
||||
rootPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
}
|
||||
folderAPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
}
|
||||
folderBPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderBName,
|
||||
}
|
||||
// For skipped test
|
||||
// subfolderAPath := []string{
|
||||
// "drives",
|
||||
// odConsts.DrivesPathDir,
|
||||
// driveID,
|
||||
// rootFolder,
|
||||
// odConsts.RootPathDir,
|
||||
// folderBName,
|
||||
// folderAName,
|
||||
// }
|
||||
folderCPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderCName,
|
||||
}
|
||||
|
||||
@ -987,9 +987,9 @@ func testPermissionsBackupAndNoRestore(suite oneDriveSuite, startVersion int) {
|
||||
inputCols := []onedriveColInfo{
|
||||
{
|
||||
pathElements: []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
},
|
||||
files: []itemData{
|
||||
{
|
||||
@ -1008,9 +1008,9 @@ func testPermissionsBackupAndNoRestore(suite oneDriveSuite, startVersion int) {
|
||||
expectedCols := []onedriveColInfo{
|
||||
{
|
||||
pathElements: []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
},
|
||||
files: []itemData{
|
||||
{
|
||||
@ -1073,34 +1073,34 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
folderCName := "empty"
|
||||
|
||||
rootPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
}
|
||||
folderAPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
}
|
||||
subfolderAAPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
folderAName,
|
||||
}
|
||||
subfolderABPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
folderBName,
|
||||
}
|
||||
subfolderACPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderAName,
|
||||
folderCName,
|
||||
}
|
||||
@ -1246,20 +1246,20 @@ func testRestoreFolderNamedFolderRegression(
|
||||
suite.BackupResourceOwner())
|
||||
|
||||
rootPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
}
|
||||
folderFolderPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderNamedFolder,
|
||||
}
|
||||
subfolderPath := []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
driveID,
|
||||
rootFolder,
|
||||
odConsts.RootPathDir,
|
||||
folderNamedFolder,
|
||||
folderBName,
|
||||
}
|
||||
|
||||
10
src/internal/connector/onedrive/consts/consts.go
Normal file
10
src/internal/connector/onedrive/consts/consts.go
Normal file
@ -0,0 +1,10 @@
|
||||
package onedrive
|
||||
|
||||
const (
|
||||
// const used as the root dir for the drive portion of a path prefix.
|
||||
// eg: tid/onedrive/ro/files/drives/driveid/...
|
||||
DrivesPathDir = "drives"
|
||||
// const used as the root-of-drive dir for the drive portion of a path prefix.
|
||||
// eg: tid/onedrive/ro/files/drives/driveid/root:/...
|
||||
RootPathDir = "root:"
|
||||
)
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||
gapi "github.com/alcionai/corso/src/internal/connector/graph/api"
|
||||
"github.com/alcionai/corso/src/internal/connector/onedrive/api"
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -71,7 +72,7 @@ func pathPrefixerForSource(
|
||||
}
|
||||
|
||||
return func(driveID string) (path.Path, error) {
|
||||
return path.Build(tenantID, resourceOwner, serv, cat, false, "drives", driveID, "root:")
|
||||
return path.Build(tenantID, resourceOwner, serv, cat, false, odConsts.DrivesPathDir, driveID, odConsts.RootPathDir)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/connector/mock"
|
||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||
odapi "github.com/alcionai/corso/src/internal/connector/onedrive/api"
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/connector/onedrive/metadata"
|
||||
"github.com/alcionai/corso/src/internal/connector/support"
|
||||
"github.com/alcionai/corso/src/internal/data"
|
||||
@ -369,7 +370,7 @@ func generateContainerOfItems(
|
||||
|
||||
switch service {
|
||||
case path.OneDriveService, path.SharePointService:
|
||||
pathFolders = []string{"drives", driveID, "root:", destFldr}
|
||||
pathFolders = []string{odConsts.DrivesPathDir, driveID, odConsts.RootPathDir, destFldr}
|
||||
}
|
||||
|
||||
collections := []incrementalCollection{{
|
||||
|
||||
@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/prefixmatcher"
|
||||
"github.com/alcionai/corso/src/internal/connector/mock"
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/data"
|
||||
evmock "github.com/alcionai/corso/src/internal/events/mock"
|
||||
"github.com/alcionai/corso/src/internal/kopia"
|
||||
@ -657,15 +658,15 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
path.OneDriveService.String(),
|
||||
ro,
|
||||
path.FilesCategory.String(),
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
"drive-id",
|
||||
"root:",
|
||||
odConsts.RootPathDir,
|
||||
"work",
|
||||
"item1",
|
||||
},
|
||||
true,
|
||||
)
|
||||
locationPath1 = path.Builder{}.Append("root:", "work-display-name")
|
||||
locationPath1 = path.Builder{}.Append(odConsts.RootPathDir, "work-display-name")
|
||||
itemPath2 = makePath(
|
||||
suite.T(),
|
||||
[]string{
|
||||
@ -673,15 +674,15 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
path.OneDriveService.String(),
|
||||
ro,
|
||||
path.FilesCategory.String(),
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
"drive-id",
|
||||
"root:",
|
||||
odConsts.RootPathDir,
|
||||
"personal",
|
||||
"item2",
|
||||
},
|
||||
true,
|
||||
)
|
||||
locationPath2 = path.Builder{}.Append("root:", "personal-display-name")
|
||||
locationPath2 = path.Builder{}.Append(odConsts.RootPathDir, "personal-display-name")
|
||||
itemPath3 = makePath(
|
||||
suite.T(),
|
||||
[]string{
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/dttm"
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/connector/onedrive/metadata"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
@ -242,9 +243,9 @@ func oneDriveishEntry(t *testing.T, id string, size int, it ItemType) Entry {
|
||||
"tenant-id",
|
||||
"user-id",
|
||||
[]string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
"drive-id",
|
||||
"root:",
|
||||
odConsts.RootPathDir,
|
||||
"Inbox",
|
||||
"folder1",
|
||||
id,
|
||||
@ -408,7 +409,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
{
|
||||
ItemInfo: ItemInfo{
|
||||
Folder: &FolderInfo{
|
||||
DisplayName: "root:",
|
||||
DisplayName: odConsts.RootPathDir,
|
||||
ItemType: FolderItem,
|
||||
DriveName: "drive-name",
|
||||
DriveID: "drive-id",
|
||||
@ -416,7 +417,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
},
|
||||
{
|
||||
LocationRef: "root:",
|
||||
LocationRef: odConsts.RootPathDir,
|
||||
ItemInfo: ItemInfo{
|
||||
Folder: &FolderInfo{
|
||||
DisplayName: "Inbox",
|
||||
@ -958,7 +959,7 @@ func (suite *DetailsUnitSuite) TestBuilder_Add_shortRefsUniqueFromFolder() {
|
||||
"a-user",
|
||||
[]string{
|
||||
"drive-id",
|
||||
"root:",
|
||||
odConsts.RootPathDir,
|
||||
"folder",
|
||||
name + "-id",
|
||||
})
|
||||
@ -971,7 +972,7 @@ func (suite *DetailsUnitSuite) TestBuilder_Add_shortRefsUniqueFromFolder() {
|
||||
"a-user",
|
||||
[]string{
|
||||
"drive-id",
|
||||
"root:",
|
||||
odConsts.RootPathDir,
|
||||
"folder",
|
||||
name + "-id",
|
||||
name,
|
||||
@ -1060,7 +1061,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
|
||||
)
|
||||
|
||||
newExchangePB := path.Builder{}.Append(folder2)
|
||||
newOneDrivePB := path.Builder{}.Append("root:", folder2)
|
||||
newOneDrivePB := path.Builder{}.Append(odConsts.RootPathDir, folder2)
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
@ -22,8 +23,6 @@ func TestOneDrivePathSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *OneDrivePathSuite) Test_ToOneDrivePath() {
|
||||
const root = "root:"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
pathElements []string
|
||||
@ -32,20 +31,28 @@ func (suite *OneDrivePathSuite) Test_ToOneDrivePath() {
|
||||
}{
|
||||
{
|
||||
name: "Not enough path elements",
|
||||
pathElements: []string{"drives", "driveID"},
|
||||
pathElements: []string{odConsts.DrivesPathDir, "driveID"},
|
||||
errCheck: assert.Error,
|
||||
},
|
||||
{
|
||||
name: "Root path",
|
||||
pathElements: []string{"drives", "driveID", root},
|
||||
expected: &path.DrivePath{DriveID: "driveID", Root: root, Folders: []string{}},
|
||||
errCheck: assert.NoError,
|
||||
pathElements: []string{odConsts.DrivesPathDir, "driveID", odConsts.RootPathDir},
|
||||
expected: &path.DrivePath{
|
||||
DriveID: "driveID",
|
||||
Root: odConsts.RootPathDir,
|
||||
Folders: []string{},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
},
|
||||
{
|
||||
name: "Deeper path",
|
||||
pathElements: []string{"drives", "driveID", root, "folder1", "folder2"},
|
||||
expected: &path.DrivePath{DriveID: "driveID", Root: root, Folders: []string{"folder1", "folder2"}},
|
||||
errCheck: assert.NoError,
|
||||
pathElements: []string{odConsts.DrivesPathDir, "driveID", odConsts.RootPathDir, "folder1", "folder2"},
|
||||
expected: &path.DrivePath{
|
||||
DriveID: "driveID",
|
||||
Root: odConsts.RootPathDir,
|
||||
Folders: []string{"folder1", "folder2"},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/dttm"
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
@ -315,7 +316,7 @@ func (suite *OneDriveSelectorSuite) TestOneDriveCategory_PathValues() {
|
||||
fileName := "file"
|
||||
fileID := fileName + "-id"
|
||||
shortRef := "short"
|
||||
elems := []string{"drives", "driveID", "root:", "dir1.d", "dir2.d", fileID}
|
||||
elems := []string{odConsts.DrivesPathDir, "driveID", odConsts.RootPathDir, "dir1.d", "dir2.d", fileID}
|
||||
|
||||
filePath, err := path.Build("tenant", "user", path.OneDriveService, path.FilesCategory, true, elems...)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/common/dttm"
|
||||
odConsts "github.com/alcionai/corso/src/internal/connector/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
@ -223,9 +224,9 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
|
||||
var (
|
||||
prefixElems = []string{
|
||||
"drives",
|
||||
odConsts.DrivesPathDir,
|
||||
"drive!id",
|
||||
"root:",
|
||||
odConsts.RootPathDir,
|
||||
}
|
||||
itemElems1 = []string{"folderA", "folderB"}
|
||||
itemElems2 = []string{"folderA", "folderC"}
|
||||
@ -257,7 +258,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
{
|
||||
RepoRef: item,
|
||||
ItemRef: "item",
|
||||
LocationRef: strings.Join(append([]string{"root:"}, itemElems1...), "/"),
|
||||
LocationRef: strings.Join(append([]string{odConsts.RootPathDir}, itemElems1...), "/"),
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointLibrary,
|
||||
@ -268,7 +269,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
},
|
||||
{
|
||||
RepoRef: item2,
|
||||
LocationRef: strings.Join(append([]string{"root:"}, itemElems2...), "/"),
|
||||
LocationRef: strings.Join(append([]string{odConsts.RootPathDir}, itemElems2...), "/"),
|
||||
// ItemRef intentionally blank to test fallback case
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
@ -281,7 +282,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
{
|
||||
RepoRef: item3,
|
||||
ItemRef: "item3",
|
||||
LocationRef: strings.Join(append([]string{"root:"}, itemElems3...), "/"),
|
||||
LocationRef: strings.Join(append([]string{odConsts.RootPathDir}, itemElems3...), "/"),
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointLibrary,
|
||||
@ -415,8 +416,15 @@ func (suite *SharePointSelectorSuite) TestSharePointCategory_PathValues() {
|
||||
itemName = "item"
|
||||
itemID = "item-id"
|
||||
shortRef = "short"
|
||||
driveElems = []string{"drives", "drive!id", "root:.d", "dir1.d", "dir2.d", itemID}
|
||||
elems = []string{"dir1", "dir2", itemID}
|
||||
driveElems = []string{
|
||||
odConsts.DrivesPathDir,
|
||||
"drive!id",
|
||||
odConsts.RootPathDir + ".d",
|
||||
"dir1.d",
|
||||
"dir2.d",
|
||||
itemID,
|
||||
}
|
||||
elems = []string{"dir1", "dir2", itemID}
|
||||
)
|
||||
|
||||
table := []struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user