add sharepoint to path (#1465)
Adds the sharepoint service to /pkg/path. Currently uses the "Files" category for its category type, which is just a placeholder for kicking off development. Additionally, uncomments selector tests that were dependent upon the path service declaration.
This commit is contained in:
parent
2f5df36c6a
commit
11371f6e94
@ -177,7 +177,7 @@ func (suite *MockExchangeDataSuite) TestMockByteHydration() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Sharepoint: List",
|
name: "SharePoint: List",
|
||||||
transformation: func(t *testing.T) error {
|
transformation: func(t *testing.T) error {
|
||||||
bytes, err := mockconnector.GetMockListBytes(subject)
|
bytes, err := mockconnector.GetMockListBytes(subject)
|
||||||
require.NoError(suite.T(), err)
|
require.NoError(suite.T(), err)
|
||||||
|
|||||||
@ -69,7 +69,7 @@ func (sc *Collection) Items() <-chan data.Stream {
|
|||||||
type Item struct {
|
type Item struct {
|
||||||
id string
|
id string
|
||||||
data io.ReadCloser
|
data io.ReadCloser
|
||||||
info *details.SharepointInfo
|
info *details.SharePointInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sd *Item) UUID() string {
|
func (sd *Item) UUID() string {
|
||||||
@ -81,7 +81,7 @@ func (sd *Item) ToReader() io.ReadCloser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sd *Item) Info() details.ItemInfo {
|
func (sd *Item) Info() details.ItemInfo {
|
||||||
return details.ItemInfo{Sharepoint: sd.info}
|
return details.ItemInfo{SharePoint: sd.info}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *Collection) finishPopulation(ctx context.Context, success int, totalBytes int64, errs error) {
|
func (sc *Collection) finishPopulation(ctx context.Context, success int, totalBytes int64, errs error) {
|
||||||
|
|||||||
@ -71,7 +71,7 @@ func (suite *SharePointCollectionSuite) TestSharePointListCollection() {
|
|||||||
col.data <- &Item{
|
col.data <- &Item{
|
||||||
id: testName,
|
id: testName,
|
||||||
data: io.NopCloser(bytes.NewReader(byteArray)),
|
data: io.NopCloser(bytes.NewReader(byteArray)),
|
||||||
info: sharepointListInfo(listing),
|
info: sharePointListInfo(listing),
|
||||||
}
|
}
|
||||||
col.finishPopulation(ctx, 0, 0, nil)
|
col.finishPopulation(ctx, 0, 0, nil)
|
||||||
|
|
||||||
@ -85,6 +85,6 @@ func (suite *SharePointCollectionSuite) TestSharePointListCollection() {
|
|||||||
shareInfo, ok := item.(data.StreamInfo)
|
shareInfo, ok := item.(data.StreamInfo)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.NotNil(t, shareInfo.Info())
|
require.NotNil(t, shareInfo.Info())
|
||||||
require.NotNil(t, shareInfo.Info().Sharepoint)
|
require.NotNil(t, shareInfo.Info().SharePoint)
|
||||||
assert.Equal(t, testName, shareInfo.Info().Sharepoint.ItemName)
|
assert.Equal(t, testName, shareInfo.Info().SharePoint.ItemName)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sharepointListInfo translates models.Listable metadata into searchable content
|
// sharePointListInfo translates models.Listable metadata into searchable content
|
||||||
// List Details: https://learn.microsoft.com/en-us/graph/api/resources/list?view=graph-rest-1.0
|
// List Details: https://learn.microsoft.com/en-us/graph/api/resources/list?view=graph-rest-1.0
|
||||||
func sharepointListInfo(lst models.Listable) *details.SharepointInfo {
|
func sharePointListInfo(lst models.Listable) *details.SharePointInfo {
|
||||||
var (
|
var (
|
||||||
name, webURL string
|
name, webURL string
|
||||||
created, modified time.Time
|
created, modified time.Time
|
||||||
@ -32,8 +32,8 @@ func sharepointListInfo(lst models.Listable) *details.SharepointInfo {
|
|||||||
modified = *lst.GetLastModifiedDateTime()
|
modified = *lst.GetLastModifiedDateTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
return &details.SharepointInfo{
|
return &details.SharePointInfo{
|
||||||
ItemType: details.SharepointItem,
|
ItemType: details.SharePointItem,
|
||||||
ItemName: name,
|
ItemName: name,
|
||||||
Created: created,
|
Created: created,
|
||||||
Modified: modified,
|
Modified: modified,
|
||||||
|
|||||||
@ -21,22 +21,22 @@ func TestSharePointInfoSuite(t *testing.T) {
|
|||||||
func (suite *SharePointInfoSuite) TestSharePointInfo() {
|
func (suite *SharePointInfoSuite) TestSharePointInfo() {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
listAndRP func() (models.Listable, *details.SharepointInfo)
|
listAndRP func() (models.Listable, *details.SharePointInfo)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Empty List",
|
name: "Empty List",
|
||||||
listAndRP: func() (models.Listable, *details.SharepointInfo) {
|
listAndRP: func() (models.Listable, *details.SharePointInfo) {
|
||||||
i := &details.SharepointInfo{ItemType: details.SharepointItem}
|
i := &details.SharePointInfo{ItemType: details.SharePointItem}
|
||||||
return models.NewList(), i
|
return models.NewList(), i
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
name: "Only Name",
|
name: "Only Name",
|
||||||
listAndRP: func() (models.Listable, *details.SharepointInfo) {
|
listAndRP: func() (models.Listable, *details.SharePointInfo) {
|
||||||
aTitle := "Whole List"
|
aTitle := "Whole List"
|
||||||
listing := models.NewList()
|
listing := models.NewList()
|
||||||
listing.SetDisplayName(&aTitle)
|
listing.SetDisplayName(&aTitle)
|
||||||
i := &details.SharepointInfo{
|
i := &details.SharePointInfo{
|
||||||
ItemType: details.SharepointItem,
|
ItemType: details.SharePointItem,
|
||||||
ItemName: aTitle,
|
ItemName: aTitle,
|
||||||
}
|
}
|
||||||
return listing, i
|
return listing, i
|
||||||
@ -46,7 +46,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo() {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
list, expected := test.listAndRP()
|
list, expected := test.listAndRP()
|
||||||
info := sharepointListInfo(list)
|
info := sharePointListInfo(list)
|
||||||
assert.Equal(t, expected.ItemType, info.ItemType)
|
assert.Equal(t, expected.ItemType, info.ItemType)
|
||||||
assert.Equal(t, expected.ItemName, info.ItemName)
|
assert.Equal(t, expected.ItemName, info.ItemName)
|
||||||
assert.Equal(t, expected.WebURL, info.WebURL)
|
assert.Equal(t, expected.WebURL, info.WebURL)
|
||||||
|
|||||||
@ -194,8 +194,8 @@ func (de DetailsEntry) Headers() []string {
|
|||||||
hs = append(hs, de.ItemInfo.Exchange.Headers()...)
|
hs = append(hs, de.ItemInfo.Exchange.Headers()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if de.ItemInfo.Sharepoint != nil {
|
if de.ItemInfo.SharePoint != nil {
|
||||||
hs = append(hs, de.ItemInfo.Sharepoint.Headers()...)
|
hs = append(hs, de.ItemInfo.SharePoint.Headers()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if de.ItemInfo.OneDrive != nil {
|
if de.ItemInfo.OneDrive != nil {
|
||||||
@ -217,8 +217,8 @@ func (de DetailsEntry) Values() []string {
|
|||||||
vs = append(vs, de.ItemInfo.Exchange.Values()...)
|
vs = append(vs, de.ItemInfo.Exchange.Values()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if de.ItemInfo.Sharepoint != nil {
|
if de.ItemInfo.SharePoint != nil {
|
||||||
vs = append(vs, de.ItemInfo.Sharepoint.Values()...)
|
vs = append(vs, de.ItemInfo.SharePoint.Values()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if de.ItemInfo.OneDrive != nil {
|
if de.ItemInfo.OneDrive != nil {
|
||||||
@ -238,7 +238,7 @@ const (
|
|||||||
ExchangeEvent
|
ExchangeEvent
|
||||||
ExchangeMail
|
ExchangeMail
|
||||||
|
|
||||||
SharepointItem ItemType = iota + 100
|
SharePointItem ItemType = iota + 100
|
||||||
|
|
||||||
OneDriveItem ItemType = iota + 200
|
OneDriveItem ItemType = iota + 200
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ const (
|
|||||||
type ItemInfo struct {
|
type ItemInfo struct {
|
||||||
Folder *FolderInfo `json:"folder,omitempty"`
|
Folder *FolderInfo `json:"folder,omitempty"`
|
||||||
Exchange *ExchangeInfo `json:"exchange,omitempty"`
|
Exchange *ExchangeInfo `json:"exchange,omitempty"`
|
||||||
Sharepoint *SharepointInfo `json:"sharepoint,omitempty"`
|
SharePoint *SharePointInfo `json:"sharePoint,omitempty"`
|
||||||
OneDrive *OneDriveInfo `json:"oneDrive,omitempty"`
|
OneDrive *OneDriveInfo `json:"oneDrive,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,8 +268,8 @@ func (i ItemInfo) infoType() ItemType {
|
|||||||
case i.Exchange != nil:
|
case i.Exchange != nil:
|
||||||
return i.Exchange.ItemType
|
return i.Exchange.ItemType
|
||||||
|
|
||||||
case i.Sharepoint != nil:
|
case i.SharePoint != nil:
|
||||||
return i.Sharepoint.ItemType
|
return i.SharePoint.ItemType
|
||||||
|
|
||||||
case i.OneDrive != nil:
|
case i.OneDrive != nil:
|
||||||
return i.OneDrive.ItemType
|
return i.OneDrive.ItemType
|
||||||
@ -344,8 +344,8 @@ func (i ExchangeInfo) Values() []string {
|
|||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SharepointInfo describes a sharepoint item
|
// SharePointInfo describes a sharepoint item
|
||||||
type SharepointInfo struct {
|
type SharePointInfo struct {
|
||||||
ItemType ItemType `json:"itemType,omitempty"`
|
ItemType ItemType `json:"itemType,omitempty"`
|
||||||
ItemName string `json:"itemName,omitempty"`
|
ItemName string `json:"itemName,omitempty"`
|
||||||
Created time.Time `json:"created,omitempty"`
|
Created time.Time `json:"created,omitempty"`
|
||||||
@ -353,15 +353,15 @@ type SharepointInfo struct {
|
|||||||
WebURL string `json:"webUrl,omitempty"`
|
WebURL string `json:"webUrl,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Headers returns the human-readable names of properties in a SharepointInfo
|
// Headers returns the human-readable names of properties in a SharePointInfo
|
||||||
// for printing out to a terminal in a columnar display.
|
// for printing out to a terminal in a columnar display.
|
||||||
func (i SharepointInfo) Headers() []string {
|
func (i SharePointInfo) Headers() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values returns the values matching the Headers list for printing
|
// Values returns the values matching the Headers list for printing
|
||||||
// out to a terminal in a columnar display.
|
// out to a terminal in a columnar display.
|
||||||
func (i SharepointInfo) Values() []string {
|
func (i SharePointInfo) Values() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
|||||||
RepoRef: "reporef",
|
RepoRef: "reporef",
|
||||||
ShortRef: "deadbeef",
|
ShortRef: "deadbeef",
|
||||||
ItemInfo: details.ItemInfo{
|
ItemInfo: details.ItemInfo{
|
||||||
Sharepoint: &details.SharepointInfo{},
|
SharePoint: &details.SharePointInfo{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectHs: []string{"ID"},
|
expectHs: []string{"ID"},
|
||||||
|
|||||||
@ -305,6 +305,27 @@ func (pb Builder) ToDataLayerOneDrivePath(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pb Builder) ToDataLayerSharePointPath(
|
||||||
|
tenant, site string,
|
||||||
|
isItem bool,
|
||||||
|
) (Path, error) {
|
||||||
|
if err := pb.verifyPrefix(tenant, site); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &dataLayerResourcePath{
|
||||||
|
Builder: *pb.withPrefix(
|
||||||
|
tenant,
|
||||||
|
SharePointService.String(),
|
||||||
|
site,
|
||||||
|
FilesCategory.String(),
|
||||||
|
),
|
||||||
|
service: SharePointService,
|
||||||
|
category: FilesCategory,
|
||||||
|
hasItem: isItem,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// FromDataLayerPath parses the escaped path p, validates the elements in p
|
// FromDataLayerPath parses the escaped path p, validates the elements in p
|
||||||
// match a resource-specific path format, and returns a Path struct for that
|
// match a resource-specific path format, and returns a Path struct for that
|
||||||
// resource-specific type. If p does not match any resource-specific paths or
|
// resource-specific type. If p does not match any resource-specific paths or
|
||||||
|
|||||||
@ -10,9 +10,10 @@ type ServiceType int
|
|||||||
|
|
||||||
//go:generate stringer -type=ServiceType -linecomment
|
//go:generate stringer -type=ServiceType -linecomment
|
||||||
const (
|
const (
|
||||||
UnknownService ServiceType = iota
|
UnknownService ServiceType = iota
|
||||||
ExchangeService // exchange
|
ExchangeService // exchange
|
||||||
OneDriveService // onedrive
|
OneDriveService // onedrive
|
||||||
|
SharePointService // sharepoint
|
||||||
)
|
)
|
||||||
|
|
||||||
func toServiceType(service string) ServiceType {
|
func toServiceType(service string) ServiceType {
|
||||||
@ -21,6 +22,8 @@ func toServiceType(service string) ServiceType {
|
|||||||
return ExchangeService
|
return ExchangeService
|
||||||
case OneDriveService.String():
|
case OneDriveService.String():
|
||||||
return OneDriveService
|
return OneDriveService
|
||||||
|
case SharePointService.String():
|
||||||
|
return SharePointService
|
||||||
default:
|
default:
|
||||||
return UnknownService
|
return UnknownService
|
||||||
}
|
}
|
||||||
@ -64,6 +67,10 @@ var serviceCategories = map[ServiceType]map[CategoryType]struct{}{
|
|||||||
OneDriveService: {
|
OneDriveService: {
|
||||||
FilesCategory: {},
|
FilesCategory: {},
|
||||||
},
|
},
|
||||||
|
SharePointService: {
|
||||||
|
// TODO: need to figure out the service Category(s) for sharepoint.
|
||||||
|
FilesCategory: {},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateServiceAndCategoryStrings(s, c string) (ServiceType, CategoryType, error) {
|
func validateServiceAndCategoryStrings(s, c string) (ServiceType, CategoryType, error) {
|
||||||
|
|||||||
@ -102,6 +102,13 @@ var (
|
|||||||
return pb.ToDataLayerOneDrivePath(tenant, user, isItem)
|
return pb.ToDataLayerOneDrivePath(tenant, user, isItem)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
service: path.SharePointService,
|
||||||
|
category: path.FilesCategory,
|
||||||
|
pathFunc: func(pb *path.Builder, tenant, user string, isItem bool) (path.Path, error) {
|
||||||
|
return pb.ToDataLayerSharePointPath(tenant, user, isItem)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -105,6 +105,14 @@ func (suite *ServiceCategoryUnitSuite) TestValidateServiceAndCategory() {
|
|||||||
expectedCategory: FilesCategory,
|
expectedCategory: FilesCategory,
|
||||||
check: assert.NoError,
|
check: assert.NoError,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "SharePointFiles",
|
||||||
|
service: SharePointService.String(),
|
||||||
|
category: FilesCategory.String(),
|
||||||
|
expectedService: SharePointService,
|
||||||
|
expectedCategory: FilesCategory,
|
||||||
|
check: assert.NoError,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
|
|||||||
@ -11,11 +11,12 @@ func _() {
|
|||||||
_ = x[UnknownService-0]
|
_ = x[UnknownService-0]
|
||||||
_ = x[ExchangeService-1]
|
_ = x[ExchangeService-1]
|
||||||
_ = x[OneDriveService-2]
|
_ = x[OneDriveService-2]
|
||||||
|
_ = x[SharePointService-3]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _ServiceType_name = "UnknownServiceexchangeonedrive"
|
const _ServiceType_name = "UnknownServiceexchangeonedrivesharepoint"
|
||||||
|
|
||||||
var _ServiceType_index = [...]uint8{0, 14, 22, 30}
|
var _ServiceType_index = [...]uint8{0, 14, 22, 30, 40}
|
||||||
|
|
||||||
func (i ServiceType) String() string {
|
func (i ServiceType) String() string {
|
||||||
if i < 0 || i >= ServiceType(len(_ServiceType_index)-1) {
|
if i < 0 || i >= ServiceType(len(_ServiceType_index)-1) {
|
||||||
|
|||||||
@ -24,10 +24,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var serviceToPathType = map[service]path.ServiceType{
|
var serviceToPathType = map[service]path.ServiceType{
|
||||||
ServiceUnknown: path.UnknownService,
|
ServiceUnknown: path.UnknownService,
|
||||||
ServiceExchange: path.ExchangeService,
|
ServiceExchange: path.ExchangeService,
|
||||||
ServiceOneDrive: path.OneDriveService,
|
ServiceOneDrive: path.OneDriveService,
|
||||||
// ServiceSharePoint: path.SharePointService, TODO: add sharepoint to path
|
ServiceSharePoint: path.SharePointService,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -78,7 +78,7 @@ type Reducer interface {
|
|||||||
// The core selector. Has no api for setting or retrieving data.
|
// The core selector. Has no api for setting or retrieving data.
|
||||||
// Is only used to pass along more specific selector instances.
|
// Is only used to pass along more specific selector instances.
|
||||||
type Selector struct {
|
type Selector struct {
|
||||||
// The service scope of the data. Exchange, Teams, Sharepoint, etc.
|
// The service scope of the data. Exchange, Teams, SharePoint, etc.
|
||||||
Service service `json:"service,omitempty"`
|
Service service `json:"service,omitempty"`
|
||||||
// A slice of exclusion scopes. Exclusions apply globally to all
|
// A slice of exclusion scopes. Exclusions apply globally to all
|
||||||
// inclusions/filters, with any-match behavior.
|
// inclusions/filters, with any-match behavior.
|
||||||
|
|||||||
@ -11,11 +11,12 @@ func _() {
|
|||||||
_ = x[ServiceUnknown-0]
|
_ = x[ServiceUnknown-0]
|
||||||
_ = x[ServiceExchange-1]
|
_ = x[ServiceExchange-1]
|
||||||
_ = x[ServiceOneDrive-2]
|
_ = x[ServiceOneDrive-2]
|
||||||
|
_ = x[ServiceSharePoint-3]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _service_name = "Unknown ServiceExchangeOneDrive"
|
const _service_name = "Unknown ServiceExchangeOneDriveSharePoint"
|
||||||
|
|
||||||
var _service_index = [...]uint8{0, 15, 23, 31}
|
var _service_index = [...]uint8{0, 15, 23, 31, 41}
|
||||||
|
|
||||||
func (i service) String() string {
|
func (i service) String() string {
|
||||||
if i < 0 || i >= service(len(_service_index)-1) {
|
if i < 0 || i >= service(len(_service_index)-1) {
|
||||||
|
|||||||
@ -240,7 +240,7 @@ var _ categorizer = SharePointCategoryUnknown
|
|||||||
const (
|
const (
|
||||||
SharePointCategoryUnknown sharePointCategory = ""
|
SharePointCategoryUnknown sharePointCategory = ""
|
||||||
// types of data identified by SharePoint
|
// types of data identified by SharePoint
|
||||||
SharePointSite sharePointCategory = "SharePointSitte"
|
SharePointSite sharePointCategory = "SharePointSite"
|
||||||
SharePointFolder sharePointCategory = "SharePointFolder"
|
SharePointFolder sharePointCategory = "SharePointFolder"
|
||||||
SharePointItem sharePointCategory = "SharePointItem"
|
SharePointItem sharePointCategory = "SharePointItem"
|
||||||
|
|
||||||
@ -428,7 +428,8 @@ func (s sharePoint) Reduce(ctx context.Context, deets *details.Details) *details
|
|||||||
deets,
|
deets,
|
||||||
s.Selector,
|
s.Selector,
|
||||||
map[path.CategoryType]sharePointCategory{
|
map[path.CategoryType]sharePointCategory{
|
||||||
// path.FilesCategory: SharePointItem,
|
// TODO: need to figure out the path Category(s) for sharepoint.
|
||||||
|
path.FilesCategory: SharePointItem,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,10 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SharePointSelectorSuite struct {
|
type SharePointSelectorSuite struct {
|
||||||
@ -175,162 +179,159 @@ func (suite *SharePointSelectorSuite) TestToSharePointRestore() {
|
|||||||
assert.NotZero(t, or.Scopes())
|
assert.NotZero(t, or.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: enable when sharepoint has path and detail representation
|
func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||||
// func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
var (
|
||||||
// var (
|
item = stubRepoRef(path.SharePointService, path.FilesCategory, "uid", "/folderA/folderB", "item")
|
||||||
// item = stubRepoRef(path.SharePointService, path.SharePointItemsCategory, "uid", "/folderA/folderB", "item")
|
item2 = stubRepoRef(path.SharePointService, path.FilesCategory, "uid", "/folderA/folderC", "item2")
|
||||||
// item2 = stubRepoRef(path.SharePointService, path.SharePointItemsCategory, "uid", "/folderA/folderC", "item2")
|
item3 = stubRepoRef(path.SharePointService, path.FilesCategory, "uid", "/folderD/folderE", "item3")
|
||||||
// item3 = stubRepoRef(path.SharePointService, path.SharePointItemsCategory, "uid", "/folderD/folderE", "item3")
|
)
|
||||||
// )
|
|
||||||
|
|
||||||
// deets := &details.Details{
|
deets := &details.Details{
|
||||||
// DetailsModel: details.DetailsModel{
|
DetailsModel: details.DetailsModel{
|
||||||
// Entries: []details.DetailsEntry{
|
Entries: []details.DetailsEntry{
|
||||||
// {
|
{
|
||||||
// RepoRef: item,
|
RepoRef: item,
|
||||||
// ItemInfo: details.ItemInfo{
|
ItemInfo: details.ItemInfo{
|
||||||
// SharePoint: &details.SharePointInfo{
|
SharePoint: &details.SharePointInfo{
|
||||||
// ItemType: details.SharePointItem,
|
ItemType: details.SharePointItem,
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// RepoRef: item2,
|
RepoRef: item2,
|
||||||
// ItemInfo: details.ItemInfo{
|
ItemInfo: details.ItemInfo{
|
||||||
// SharePoint: &details.SharePointInfo{
|
SharePoint: &details.SharePointInfo{
|
||||||
// ItemType: details.SharePointItem,
|
ItemType: details.SharePointItem,
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// RepoRef: item3,
|
RepoRef: item3,
|
||||||
// ItemInfo: details.ItemInfo{
|
ItemInfo: details.ItemInfo{
|
||||||
// SharePoint: &details.SharePointInfo{
|
SharePoint: &details.SharePointInfo{
|
||||||
// ItemType: details.SharePointItem,
|
ItemType: details.SharePointItem,
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
|
|
||||||
// arr := func(s ...string) []string {
|
arr := func(s ...string) []string {
|
||||||
// return s
|
return s
|
||||||
// }
|
}
|
||||||
|
|
||||||
// table := []struct {
|
table := []struct {
|
||||||
// name string
|
name string
|
||||||
// deets *details.Details
|
deets *details.Details
|
||||||
// makeSelector func() *SharePointRestore
|
makeSelector func() *SharePointRestore
|
||||||
// expect []string
|
expect []string
|
||||||
// }{
|
}{
|
||||||
// {
|
{
|
||||||
// "all",
|
"all",
|
||||||
// deets,
|
deets,
|
||||||
// func() *SharePointRestore {
|
func() *SharePointRestore {
|
||||||
// odr := NewSharePointRestore()
|
odr := NewSharePointRestore()
|
||||||
// odr.Include(odr.Sites(Any()))
|
odr.Include(odr.Sites(Any()))
|
||||||
// return odr
|
return odr
|
||||||
// },
|
},
|
||||||
// arr(item, item2, item3),
|
arr(item, item2, item3),
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// "only match item",
|
"only match item",
|
||||||
// deets,
|
deets,
|
||||||
// func() *SharePointRestore {
|
func() *SharePointRestore {
|
||||||
// odr := NewSharePointRestore()
|
odr := NewSharePointRestore()
|
||||||
// odr.Include(odr.Items(Any(), Any(), []string{"item2"}))
|
odr.Include(odr.Items(Any(), Any(), []string{"item2"}))
|
||||||
// return odr
|
return odr
|
||||||
// },
|
},
|
||||||
// arr(item2),
|
arr(item2),
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// "only match folder",
|
"only match folder",
|
||||||
// deets,
|
deets,
|
||||||
// func() *SharePointRestore {
|
func() *SharePointRestore {
|
||||||
// odr := NewSharePointRestore()
|
odr := NewSharePointRestore()
|
||||||
// odr.Include(odr.Folders([]string{"uid"}, []string{"folderA/folderB", "folderA/folderC"}))
|
odr.Include(odr.Folders([]string{"uid"}, []string{"folderA/folderB", "folderA/folderC"}))
|
||||||
// return odr
|
return odr
|
||||||
// },
|
},
|
||||||
// arr(item, item2),
|
arr(item, item2),
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// for _, test := range table {
|
for _, test := range table {
|
||||||
// suite.T().Run(test.name, func(t *testing.T) {
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
// ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
// defer flush()
|
defer flush()
|
||||||
|
|
||||||
// sel := test.makeSelector()
|
sel := test.makeSelector()
|
||||||
// results := sel.Reduce(ctx, test.deets)
|
results := sel.Reduce(ctx, test.deets)
|
||||||
// paths := results.Paths()
|
paths := results.Paths()
|
||||||
// assert.Equal(t, test.expect, paths)
|
assert.Equal(t, test.expect, paths)
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (suite *SharePointSelectorSuite) TestSharePointCategory_PathValues() {
|
func (suite *SharePointSelectorSuite) TestSharePointCategory_PathValues() {
|
||||||
// t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
// pathBuilder := path.Builder{}.Append("dir1", "dir2", "item")
|
pathBuilder := path.Builder{}.Append("dir1", "dir2", "item")
|
||||||
// itemPath, err := pathBuilder.ToDataLayerSharePointPath("tenant", "site", true)
|
itemPath, err := pathBuilder.ToDataLayerSharePointPath("tenant", "site", true)
|
||||||
// require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// expected := map[categorizer]string{
|
expected := map[categorizer]string{
|
||||||
// SharePointSite: "site",
|
SharePointSite: "site",
|
||||||
// SharePointFolder: "dir1/dir2",
|
SharePointFolder: "dir1/dir2",
|
||||||
// SharePointItem: "item",
|
SharePointItem: "item",
|
||||||
// }
|
}
|
||||||
|
|
||||||
// assert.Equal(t, expected, SharePointItem.pathValues(itemPath))
|
assert.Equal(t, expected, SharePointItem.pathValues(itemPath))
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
|
func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
|
||||||
// ods := NewSharePointRestore()
|
ods := NewSharePointRestore()
|
||||||
|
|
||||||
// var (
|
// var url = "www.website.com"
|
||||||
// url = "www.website.com"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// itemInfo := details.ItemInfo{
|
itemInfo := details.ItemInfo{
|
||||||
// SharePoint: &details.SharepointInfo{
|
SharePoint: &details.SharePointInfo{
|
||||||
// ItemType: details.SharePointItem,
|
ItemType: details.SharePointItem,
|
||||||
// WebURL: "www.website.com",
|
// WebURL: "www.website.com",
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
|
|
||||||
// table := []struct {
|
table := []struct {
|
||||||
// name string
|
name string
|
||||||
// scope []SharePointScope
|
scope []SharePointScope
|
||||||
// expect assert.BoolAssertionFunc
|
expect assert.BoolAssertionFunc
|
||||||
// }{
|
}{
|
||||||
// {"item webURL match", ods.WebURL(url), assert.True},
|
// {"item webURL match", ods.WebURL(url), assert.True},
|
||||||
// {"item webURL substring", ods.WebURL("website"), assert.True},
|
// {"item webURL substring", ods.WebURL("website"), assert.True},
|
||||||
// {"item webURL mismatch", ods.WebURL("google"), assert.False},
|
{"item webURL mismatch", ods.WebURL("google"), assert.False},
|
||||||
// }
|
}
|
||||||
// for _, test := range table {
|
for _, test := range table {
|
||||||
// suite.T().Run(test.name, func(t *testing.T) {
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
// scopes := setScopesToDefault(test.scope)
|
scopes := setScopesToDefault(test.scope)
|
||||||
// for _, scope := range scopes {
|
for _, scope := range scopes {
|
||||||
// test.expect(t, scope.matchesInfo(itemInfo))
|
test.expect(t, scope.matchesInfo(itemInfo))
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (suite *SharePointSelectorSuite) TestCategory_PathType() {
|
func (suite *SharePointSelectorSuite) TestCategory_PathType() {
|
||||||
// table := []struct {
|
table := []struct {
|
||||||
// cat sharePointCategory
|
cat sharePointCategory
|
||||||
// pathType path.CategoryType
|
pathType path.CategoryType
|
||||||
// }{
|
}{
|
||||||
// {SharePointCategoryUnknown, path.UnknownCategory},
|
{SharePointCategoryUnknown, path.UnknownCategory},
|
||||||
// {SharePointSite, path.UnknownCategory},
|
{SharePointSite, path.UnknownCategory},
|
||||||
// {SharePointFolder, path.SharePointItemCategory},
|
{SharePointFolder, path.FilesCategory},
|
||||||
// {SharePointItem, path.SharePointItemCategory},
|
{SharePointItem, path.FilesCategory},
|
||||||
// {SharePointFilterWebURL, path.SharePointItemCategory},
|
{SharePointFilterWebURL, path.FilesCategory},
|
||||||
// }
|
}
|
||||||
// for _, test := range table {
|
for _, test := range table {
|
||||||
// suite.T().Run(test.cat.String(), func(t *testing.T) {
|
suite.T().Run(test.cat.String(), func(t *testing.T) {
|
||||||
// assert.Equal(t, test.pathType, test.cat.PathType())
|
assert.Equal(t, test.pathType, test.cat.PathType())
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user