Compare commits
1 Commits
main
...
pager-cent
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62ce55d742 |
@ -46,11 +46,7 @@ func (d *Details) add(
|
|||||||
|
|
||||||
// Use the item name and the path for the ShortRef. This ensures that renames
|
// Use the item name and the path for the ShortRef. This ensures that renames
|
||||||
// within a directory generate unique ShortRefs.
|
// within a directory generate unique ShortRefs.
|
||||||
if info.infoType() == OneDriveItem || info.infoType() == SharePointLibrary {
|
if info.isDriveItem() {
|
||||||
if info.OneDrive == nil && info.SharePoint == nil {
|
|
||||||
return entry, clues.New("item is not SharePoint or OneDrive type")
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean metadata suffixes from item refs
|
// clean metadata suffixes from item refs
|
||||||
entry.ItemRef = withoutMetadataSuffix(entry.ItemRef)
|
entry.ItemRef = withoutMetadataSuffix(entry.ItemRef)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,3 +182,14 @@ func (i ItemInfo) updateFolder(f *FolderInfo) error {
|
|||||||
return clues.New("unsupported type")
|
return clues.New("unsupported type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// true if the info represents an item backed by the drive api.
|
||||||
|
func (i ItemInfo) isDriveItem() bool {
|
||||||
|
iit := i.infoType()
|
||||||
|
|
||||||
|
if !(iit == OneDriveItem || iit == SharePointLibrary) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return !(i.OneDrive == nil && i.SharePoint == nil && i.Groups == nil)
|
||||||
|
}
|
||||||
|
|||||||
86
src/pkg/backup/details/iteminfo_test.go
Normal file
86
src/pkg/backup/details/iteminfo_test.go
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package details
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ItemInfoUnitSuite struct {
|
||||||
|
tester.Suite
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestItemInfoUnitSuite(t *testing.T) {
|
||||||
|
suite.Run(t, &ItemInfoUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *ItemInfoUnitSuite) TestItemInfo_IsDriveItem() {
|
||||||
|
table := []struct {
|
||||||
|
name string
|
||||||
|
ii ItemInfo
|
||||||
|
expect assert.BoolAssertionFunc
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "onedrive item",
|
||||||
|
ii: ItemInfo{
|
||||||
|
OneDrive: &OneDriveInfo{
|
||||||
|
ItemType: OneDriveItem,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: assert.True,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "sharepoint library",
|
||||||
|
ii: ItemInfo{
|
||||||
|
SharePoint: &SharePointInfo{
|
||||||
|
ItemType: SharePointLibrary,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: assert.True,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "sharepoint page",
|
||||||
|
ii: ItemInfo{
|
||||||
|
SharePoint: &SharePointInfo{
|
||||||
|
ItemType: SharePointPage,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: assert.False,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "groups library",
|
||||||
|
ii: ItemInfo{
|
||||||
|
Groups: &GroupsInfo{
|
||||||
|
ItemType: SharePointLibrary,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: assert.True,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "groups channel message",
|
||||||
|
ii: ItemInfo{
|
||||||
|
Groups: &GroupsInfo{
|
||||||
|
ItemType: GroupsChannelMessage,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: assert.False,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exchange anything",
|
||||||
|
ii: ItemInfo{
|
||||||
|
Groups: &GroupsInfo{
|
||||||
|
ItemType: ExchangeMail,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: assert.False,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range table {
|
||||||
|
suite.Run(test.name, func() {
|
||||||
|
test.expect(suite.T(), test.ii.isDriveItem())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user