name cleanup in selectors and onedrive (#643)
This commit is contained in:
parent
2d88e59cd0
commit
15b12e634d
@ -84,7 +84,7 @@ func (oc *Collection) FullPath() []string {
|
|||||||
type Item struct {
|
type Item struct {
|
||||||
id string
|
id string
|
||||||
data io.ReadCloser
|
data io.ReadCloser
|
||||||
info *details.OnedriveInfo
|
info *details.OneDriveInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (od *Item) UUID() string {
|
func (od *Item) UUID() string {
|
||||||
@ -96,7 +96,7 @@ func (od *Item) ToReader() io.ReadCloser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (od *Item) Info() details.ItemInfo {
|
func (od *Item) Info() details.ItemInfo {
|
||||||
return details.ItemInfo{Onedrive: od.info}
|
return details.ItemInfo{OneDrive: od.info}
|
||||||
}
|
}
|
||||||
|
|
||||||
// populateItems iterates through items added to the collection
|
// populateItems iterates through items added to the collection
|
||||||
@ -119,7 +119,7 @@ func (oc *Collection) populateItems(ctx context.Context) {
|
|||||||
oc.data <- &Item{
|
oc.data <- &Item{
|
||||||
id: itemID,
|
id: itemID,
|
||||||
data: itemData,
|
data: itemData,
|
||||||
info: &details.OnedriveInfo{ItemName: itemName, ParentPath: oc.folderPath},
|
info: &details.OneDriveInfo{ItemName: itemName, ParentPath: oc.folderPath},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(oc.data)
|
close(oc.data)
|
||||||
|
|||||||
@ -17,30 +17,30 @@ import (
|
|||||||
"github.com/alcionai/corso/internal/data"
|
"github.com/alcionai/corso/internal/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OnedriveCollectionSuite struct {
|
type OneDriveCollectionSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows `*OnedriveCollectionSuite` to be used as a graph.Service
|
// Allows `*OneDriveCollectionSuite` to be used as a graph.Service
|
||||||
// TODO: Implement these methods
|
// TODO: Implement these methods
|
||||||
|
|
||||||
func (suite *OnedriveCollectionSuite) Client() *msgraphsdk.GraphServiceClient {
|
func (suite *OneDriveCollectionSuite) Client() *msgraphsdk.GraphServiceClient {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveCollectionSuite) Adapter() *msgraphsdk.GraphRequestAdapter {
|
func (suite *OneDriveCollectionSuite) Adapter() *msgraphsdk.GraphRequestAdapter {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveCollectionSuite) ErrPolicy() bool {
|
func (suite *OneDriveCollectionSuite) ErrPolicy() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOnedriveCollectionSuite(t *testing.T) {
|
func TestOneDriveCollectionSuite(t *testing.T) {
|
||||||
suite.Run(t, new(OnedriveCollectionSuite))
|
suite.Run(t, new(OneDriveCollectionSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveCollectionSuite) TestOnedriveCollection() {
|
func (suite *OneDriveCollectionSuite) TestOneDriveCollection() {
|
||||||
folderPath := "dir1/dir2/dir3"
|
folderPath := "dir1/dir2/dir3"
|
||||||
coll := NewCollection(folderPath, "fakeDriveID", suite, nil)
|
coll := NewCollection(folderPath, "fakeDriveID", suite, nil)
|
||||||
require.NotNil(suite.T(), coll)
|
require.NotNil(suite.T(), coll)
|
||||||
@ -76,12 +76,12 @@ func (suite *OnedriveCollectionSuite) TestOnedriveCollection() {
|
|||||||
|
|
||||||
assert.Equal(suite.T(), testItemData, readData)
|
assert.Equal(suite.T(), testItemData, readData)
|
||||||
require.NotNil(suite.T(), readItemInfo.Info())
|
require.NotNil(suite.T(), readItemInfo.Info())
|
||||||
require.NotNil(suite.T(), readItemInfo.Info().Onedrive)
|
require.NotNil(suite.T(), readItemInfo.Info().OneDrive)
|
||||||
assert.Equal(suite.T(), testItemName, readItemInfo.Info().Onedrive.ItemName)
|
assert.Equal(suite.T(), testItemName, readItemInfo.Info().OneDrive.ItemName)
|
||||||
assert.Equal(suite.T(), folderPath, readItemInfo.Info().Onedrive.ParentPath)
|
assert.Equal(suite.T(), folderPath, readItemInfo.Info().OneDrive.ParentPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveCollectionSuite) TestOnedriveCollectionReadError() {
|
func (suite *OneDriveCollectionSuite) TestOneDriveCollectionReadError() {
|
||||||
coll := NewCollection("folderPath", "fakeDriveID", suite, nil)
|
coll := NewCollection("folderPath", "fakeDriveID", suite, nil)
|
||||||
coll.Add("testItemID")
|
coll.Add("testItemID")
|
||||||
|
|
||||||
|
|||||||
@ -94,8 +94,8 @@ func (de DetailsEntry) Headers() []string {
|
|||||||
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 {
|
||||||
hs = append(hs, de.ItemInfo.Onedrive.Headers()...)
|
hs = append(hs, de.ItemInfo.OneDrive.Headers()...)
|
||||||
}
|
}
|
||||||
return hs
|
return hs
|
||||||
}
|
}
|
||||||
@ -109,8 +109,8 @@ func (de DetailsEntry) Values() []string {
|
|||||||
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 {
|
||||||
vs = append(vs, de.ItemInfo.Onedrive.Values()...)
|
vs = append(vs, de.ItemInfo.OneDrive.Values()...)
|
||||||
}
|
}
|
||||||
return vs
|
return vs
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ func (de DetailsEntry) Values() []string {
|
|||||||
type ItemInfo struct {
|
type ItemInfo struct {
|
||||||
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExchangeInfo describes an exchange item
|
// ExchangeInfo describes an exchange item
|
||||||
@ -162,20 +162,20 @@ func (s SharepointInfo) Values() []string {
|
|||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnedriveInfo describes a onedrive item
|
// OneDriveInfo describes a oneDrive item
|
||||||
type OnedriveInfo struct {
|
type OneDriveInfo struct {
|
||||||
ParentPath string `json:"parentPath"`
|
ParentPath string `json:"parentPath"`
|
||||||
ItemName string `json:"itemName"`
|
ItemName string `json:"itemName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Headers returns the human-readable names of properties in a OnedriveInfo
|
// Headers returns the human-readable names of properties in a OneDriveInfo
|
||||||
// for printing out to a terminal in a columnar display.
|
// for printing out to a terminal in a columnar display.
|
||||||
func (oi OnedriveInfo) Headers() []string {
|
func (oi OneDriveInfo) Headers() []string {
|
||||||
return []string{"ItemName", "ParentPath"}
|
return []string{"ItemName", "ParentPath"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 (oi OnedriveInfo) Values() []string {
|
func (oi OneDriveInfo) Values() []string {
|
||||||
return []string{oi.ItemName, oi.ParentPath}
|
return []string{oi.ItemName, oi.ParentPath}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,11 +160,11 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
|||||||
expectVs: []string{"reporef"},
|
expectVs: []string{"reporef"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "onedrive info",
|
name: "oneDrive info",
|
||||||
entry: details.DetailsEntry{
|
entry: details.DetailsEntry{
|
||||||
RepoRef: "reporef",
|
RepoRef: "reporef",
|
||||||
ItemInfo: details.ItemInfo{
|
ItemInfo: details.ItemInfo{
|
||||||
Onedrive: &details.OnedriveInfo{
|
OneDrive: &details.OneDriveInfo{
|
||||||
ItemName: "itemName",
|
ItemName: "itemName",
|
||||||
ParentPath: "parentPath",
|
ParentPath: "parentPath",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -145,9 +145,9 @@ func (s *exchange) Scopes() []ExchangeScope {
|
|||||||
|
|
||||||
// DiscreteScopes retrieves the list of exchangeScopes in the selector.
|
// DiscreteScopes retrieves the list of exchangeScopes in the selector.
|
||||||
// If any Include scope's User category is set to Any, replaces that
|
// If any Include scope's User category is set to Any, replaces that
|
||||||
// scope's value with the list of userIDs instead.
|
// scope's value with the list of userPNs instead.
|
||||||
func (s *exchange) DiscreteScopes(userIDs []string) []ExchangeScope {
|
func (s *exchange) DiscreteScopes(userPNs []string) []ExchangeScope {
|
||||||
return discreteScopes[ExchangeScope](s.Selector, ExchangeUser, userIDs)
|
return discreteScopes[ExchangeScope](s.Selector, ExchangeUser, userPNs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------
|
// -------------------
|
||||||
@ -440,12 +440,12 @@ func (ec exchangeCategory) unknownCat() categorizer {
|
|||||||
// transforms a path to a map of identified properties.
|
// transforms a path to a map of identified properties.
|
||||||
// TODO: this should use service-specific funcs in the Paths pkg. Instead of
|
// TODO: this should use service-specific funcs in the Paths pkg. Instead of
|
||||||
// peeking at the path directly, the caller should compare against values like
|
// peeking at the path directly, the caller should compare against values like
|
||||||
// path.UserID() and path.Folders().
|
// path.UserPN() and path.Folders().
|
||||||
//
|
//
|
||||||
// Malformed (ie, short len) paths will return incomplete results.
|
// Malformed (ie, short len) paths will return incomplete results.
|
||||||
// Example:
|
// Example:
|
||||||
// [tenantID, userID, "mail", mailFolder, mailID]
|
// [tenantID, userPN, "mail", mailFolder, mailID]
|
||||||
// => {exchUser: userID, exchMailFolder: mailFolder, exchMail: mailID}
|
// => {exchUser: userPN, exchMailFolder: mailFolder, exchMail: mailID}
|
||||||
func (ec exchangeCategory) pathValues(path []string) map[categorizer]string {
|
func (ec exchangeCategory) pathValues(path []string) map[categorizer]string {
|
||||||
m := map[categorizer]string{}
|
m := map[categorizer]string{}
|
||||||
if len(path) < 2 {
|
if len(path) < 2 {
|
||||||
|
|||||||
@ -12,22 +12,22 @@ import (
|
|||||||
"github.com/alcionai/corso/pkg/backup/details"
|
"github.com/alcionai/corso/pkg/backup/details"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ExchangeSourceSuite struct {
|
type ExchangeSelectorSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExchangeSourceSuite(t *testing.T) {
|
func TestExchangeSelectorSuite(t *testing.T) {
|
||||||
suite.Run(t, new(ExchangeSourceSuite))
|
suite.Run(t, new(ExchangeSelectorSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestNewExchangeBackup() {
|
func (suite *ExchangeSelectorSuite) TestNewExchangeBackup() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
eb := NewExchangeBackup()
|
eb := NewExchangeBackup()
|
||||||
assert.Equal(t, eb.Service, ServiceExchange)
|
assert.Equal(t, eb.Service, ServiceExchange)
|
||||||
assert.NotZero(t, eb.Scopes())
|
assert.NotZero(t, eb.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestToExchangeBackup() {
|
func (suite *ExchangeSelectorSuite) TestToExchangeBackup() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
eb := NewExchangeBackup()
|
eb := NewExchangeBackup()
|
||||||
s := eb.Selector
|
s := eb.Selector
|
||||||
@ -37,14 +37,14 @@ func (suite *ExchangeSourceSuite) TestToExchangeBackup() {
|
|||||||
assert.NotZero(t, eb.Scopes())
|
assert.NotZero(t, eb.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestNewExchangeRestore() {
|
func (suite *ExchangeSelectorSuite) TestNewExchangeRestore() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
er := NewExchangeRestore()
|
er := NewExchangeRestore()
|
||||||
assert.Equal(t, er.Service, ServiceExchange)
|
assert.Equal(t, er.Service, ServiceExchange)
|
||||||
assert.NotZero(t, er.Scopes())
|
assert.NotZero(t, er.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestToExchangeRestore() {
|
func (suite *ExchangeSelectorSuite) TestToExchangeRestore() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
eb := NewExchangeRestore()
|
eb := NewExchangeRestore()
|
||||||
s := eb.Selector
|
s := eb.Selector
|
||||||
@ -54,7 +54,7 @@ func (suite *ExchangeSourceSuite) TestToExchangeRestore() {
|
|||||||
assert.NotZero(t, eb.Scopes())
|
assert.NotZero(t, eb.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Contacts() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Exclude_Contacts() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Contacts() {
|
|||||||
assert.Equal(t, scope[ExchangeContact.String()], join(c1, c2))
|
assert.Equal(t, scope[ExchangeContact.String()], join(c1, c2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Contacts() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Include_Contacts() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Contacts() {
|
|||||||
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeContact)
|
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeContact)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_ContactFolders() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Exclude_ContactFolders() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_ContactFolders()
|
|||||||
assert.Equal(t, scope[ExchangeContact.String()], AnyTgt)
|
assert.Equal(t, scope[ExchangeContact.String()], AnyTgt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_ContactFolders() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Include_ContactFolders() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_ContactFolders()
|
|||||||
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeContactFolder)
|
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeContactFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Events() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Exclude_Events() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Events() {
|
|||||||
assert.Equal(t, scope[ExchangeEvent.String()], join(e1, e2))
|
assert.Equal(t, scope[ExchangeEvent.String()], join(e1, e2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Events() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Include_Events() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Events() {
|
|||||||
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeEvent)
|
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Mails() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Exclude_Mails() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Mails() {
|
|||||||
assert.Equal(t, scope[ExchangeMail.String()], join(m1, m2))
|
assert.Equal(t, scope[ExchangeMail.String()], join(m1, m2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Mails() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Include_Mails() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Mails() {
|
|||||||
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeMail)
|
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeMail)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_MailFolders() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Exclude_MailFolders() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_MailFolders() {
|
|||||||
assert.Equal(t, scope[ExchangeMail.String()], AnyTgt)
|
assert.Equal(t, scope[ExchangeMail.String()], AnyTgt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_MailFolders() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Include_MailFolders() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_MailFolders() {
|
|||||||
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeMailFolder)
|
assert.Equal(t, sel.Scopes()[0].Category(), ExchangeMailFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Users() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Exclude_Users() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Exclude_Users() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Users() {
|
func (suite *ExchangeSelectorSuite) TestExchangeSelector_Include_Users() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewExchangeBackup()
|
sel := NewExchangeBackup()
|
||||||
|
|
||||||
@ -324,13 +324,13 @@ func (suite *ExchangeSourceSuite) TestExchangeSelector_Include_Users() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestNewExchangeDestination() {
|
func (suite *ExchangeSelectorSuite) TestNewExchangeDestination() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
dest := NewExchangeDestination()
|
dest := NewExchangeDestination()
|
||||||
assert.Len(t, dest, 0)
|
assert.Len(t, dest, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeDestination_Set() {
|
func (suite *ExchangeSelectorSuite) TestExchangeDestination_Set() {
|
||||||
dest := NewExchangeDestination()
|
dest := NewExchangeDestination()
|
||||||
|
|
||||||
table := []exchangeCategory{
|
table := []exchangeCategory{
|
||||||
@ -352,7 +352,7 @@ func (suite *ExchangeSourceSuite) TestExchangeDestination_Set() {
|
|||||||
assert.NoError(suite.T(), dest.Set(ExchangeUser, ""))
|
assert.NoError(suite.T(), dest.Set(ExchangeUser, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeDestination_GetOrDefault() {
|
func (suite *ExchangeSelectorSuite) TestExchangeDestination_GetOrDefault() {
|
||||||
dest := NewExchangeDestination()
|
dest := NewExchangeDestination()
|
||||||
|
|
||||||
table := []exchangeCategory{
|
table := []exchangeCategory{
|
||||||
@ -373,7 +373,7 @@ func (suite *ExchangeSourceSuite) TestExchangeDestination_GetOrDefault() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeBackup_Scopes() {
|
func (suite *ExchangeSelectorSuite) TestExchangeBackup_Scopes() {
|
||||||
eb := NewExchangeBackup()
|
eb := NewExchangeBackup()
|
||||||
eb.Include(eb.Users(Any()))
|
eb.Include(eb.Users(Any()))
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ func (suite *ExchangeSourceSuite) TestExchangeBackup_Scopes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeBackup_DiscreteScopes() {
|
func (suite *ExchangeSelectorSuite) TestExchangeBackup_DiscreteScopes() {
|
||||||
usrs := []string{"u1", "u2"}
|
usrs := []string{"u1", "u2"}
|
||||||
table := []struct {
|
table := []struct {
|
||||||
name string
|
name string
|
||||||
@ -438,7 +438,7 @@ func (suite *ExchangeSourceSuite) TestExchangeBackup_DiscreteScopes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeScope_Category() {
|
func (suite *ExchangeSelectorSuite) TestExchangeScope_Category() {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
is exchangeCategory
|
is exchangeCategory
|
||||||
expect exchangeCategory
|
expect exchangeCategory
|
||||||
@ -469,7 +469,7 @@ func (suite *ExchangeSourceSuite) TestExchangeScope_Category() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeScope_IncludesCategory() {
|
func (suite *ExchangeSelectorSuite) TestExchangeScope_IncludesCategory() {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
is exchangeCategory
|
is exchangeCategory
|
||||||
expect exchangeCategory
|
expect exchangeCategory
|
||||||
@ -501,7 +501,7 @@ func (suite *ExchangeSourceSuite) TestExchangeScope_IncludesCategory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeScope_Get() {
|
func (suite *ExchangeSelectorSuite) TestExchangeScope_Get() {
|
||||||
eb := NewExchangeBackup()
|
eb := NewExchangeBackup()
|
||||||
eb.Include(eb.Users(Any()))
|
eb.Include(eb.Users(Any()))
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ func (suite *ExchangeSourceSuite) TestExchangeScope_Get() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeScope_MatchesInfo() {
|
func (suite *ExchangeSelectorSuite) TestExchangeScope_MatchesInfo() {
|
||||||
es := NewExchangeRestore()
|
es := NewExchangeRestore()
|
||||||
const (
|
const (
|
||||||
sender = "smarf@2many.cooks"
|
sender = "smarf@2many.cooks"
|
||||||
@ -584,7 +584,7 @@ func (suite *ExchangeSourceSuite) TestExchangeScope_MatchesInfo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeScope_MatchesPath() {
|
func (suite *ExchangeSelectorSuite) TestExchangeScope_MatchesPath() {
|
||||||
const (
|
const (
|
||||||
usr = "userID"
|
usr = "userID"
|
||||||
fld = "mailFolder"
|
fld = "mailFolder"
|
||||||
@ -632,7 +632,7 @@ func (suite *ExchangeSourceSuite) TestExchangeScope_MatchesPath() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestIdPath() {
|
func (suite *ExchangeSelectorSuite) TestIdPath() {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
cat exchangeCategory
|
cat exchangeCategory
|
||||||
path []string
|
path []string
|
||||||
@ -677,7 +677,7 @@ func (suite *ExchangeSourceSuite) TestIdPath() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeRestore_Reduce() {
|
func (suite *ExchangeSelectorSuite) TestExchangeRestore_Reduce() {
|
||||||
makeDeets := func(refs ...string) *details.Details {
|
makeDeets := func(refs ...string) *details.Details {
|
||||||
deets := &details.Details{
|
deets := &details.Details{
|
||||||
DetailsModel: details.DetailsModel{
|
DetailsModel: details.DetailsModel{
|
||||||
@ -829,7 +829,7 @@ func (suite *ExchangeSourceSuite) TestExchangeRestore_Reduce() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestScopesByCategory() {
|
func (suite *ExchangeSelectorSuite) TestScopesByCategory() {
|
||||||
var (
|
var (
|
||||||
es = NewExchangeRestore()
|
es = NewExchangeRestore()
|
||||||
users = es.Users(Any())
|
users = es.Users(Any())
|
||||||
@ -878,7 +878,7 @@ func (suite *ExchangeSourceSuite) TestScopesByCategory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestPasses() {
|
func (suite *ExchangeSelectorSuite) TestPasses() {
|
||||||
deets := details.DetailsEntry{}
|
deets := details.DetailsEntry{}
|
||||||
const (
|
const (
|
||||||
mid = "mailID"
|
mid = "mailID"
|
||||||
@ -932,7 +932,7 @@ func (suite *ExchangeSourceSuite) TestPasses() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestContains() {
|
func (suite *ExchangeSelectorSuite) TestContains() {
|
||||||
target := "fnords"
|
target := "fnords"
|
||||||
var (
|
var (
|
||||||
es = NewExchangeRestore()
|
es = NewExchangeRestore()
|
||||||
@ -969,7 +969,7 @@ func (suite *ExchangeSourceSuite) TestContains() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestIsAny() {
|
func (suite *ExchangeSelectorSuite) TestIsAny() {
|
||||||
var (
|
var (
|
||||||
es = NewExchangeRestore()
|
es = NewExchangeRestore()
|
||||||
anyUser = setScopesToDefault(es.Users(Any()))
|
anyUser = setScopesToDefault(es.Users(Any()))
|
||||||
@ -1003,7 +1003,7 @@ func (suite *ExchangeSourceSuite) TestIsAny() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeCategory_leafCat() {
|
func (suite *ExchangeSelectorSuite) TestExchangeCategory_leafCat() {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
cat exchangeCategory
|
cat exchangeCategory
|
||||||
expect exchangeCategory
|
expect exchangeCategory
|
||||||
@ -1023,7 +1023,7 @@ func (suite *ExchangeSourceSuite) TestExchangeCategory_leafCat() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeCategory_PathValues() {
|
func (suite *ExchangeSelectorSuite) TestExchangeCategory_PathValues() {
|
||||||
contactPath := []string{"ten", "user", "contact", "cfolder", "contactitem"}
|
contactPath := []string{"ten", "user", "contact", "cfolder", "contactitem"}
|
||||||
contactMap := map[categorizer]string{
|
contactMap := map[categorizer]string{
|
||||||
ExchangeUser: contactPath[1],
|
ExchangeUser: contactPath[1],
|
||||||
@ -1059,7 +1059,7 @@ func (suite *ExchangeSourceSuite) TestExchangeCategory_PathValues() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestExchangeCategory_PathKeys() {
|
func (suite *ExchangeSelectorSuite) TestExchangeCategory_PathKeys() {
|
||||||
contact := []categorizer{ExchangeUser, ExchangeContactFolder, ExchangeContact}
|
contact := []categorizer{ExchangeUser, ExchangeContactFolder, ExchangeContact}
|
||||||
event := []categorizer{ExchangeUser, ExchangeEvent}
|
event := []categorizer{ExchangeUser, ExchangeEvent}
|
||||||
mail := []categorizer{ExchangeUser, ExchangeMailFolder, ExchangeMail}
|
mail := []categorizer{ExchangeUser, ExchangeMailFolder, ExchangeMail}
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import (
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// onedrive provides an api for selecting
|
// oneDrive provides an api for selecting
|
||||||
// data scopes applicable to the OneDrive service.
|
// data scopes applicable to the OneDrive service.
|
||||||
onedrive struct {
|
oneDrive struct {
|
||||||
Selector
|
Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,14 +19,14 @@ type (
|
|||||||
// data scopes applicable to the OneDrive service,
|
// data scopes applicable to the OneDrive service,
|
||||||
// plus backup-specific methods.
|
// plus backup-specific methods.
|
||||||
OneDriveBackup struct {
|
OneDriveBackup struct {
|
||||||
onedrive
|
oneDrive
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewOneDriveBackup produces a new Selector with the service set to ServiceOneDrive.
|
// NewOneDriveBackup produces a new Selector with the service set to ServiceOneDrive.
|
||||||
func NewOneDriveBackup() *OneDriveBackup {
|
func NewOneDriveBackup() *OneDriveBackup {
|
||||||
src := OneDriveBackup{
|
src := OneDriveBackup{
|
||||||
onedrive{
|
oneDrive{
|
||||||
newSelector(ServiceOneDrive),
|
newSelector(ServiceOneDrive),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ func (s Selector) ToOneDriveBackup() (*OneDriveBackup, error) {
|
|||||||
if s.Service != ServiceOneDrive {
|
if s.Service != ServiceOneDrive {
|
||||||
return nil, badCastErr(ServiceOneDrive, s.Service)
|
return nil, badCastErr(ServiceOneDrive, s.Service)
|
||||||
}
|
}
|
||||||
src := OneDriveBackup{onedrive{s}}
|
src := OneDriveBackup{oneDrive{s}}
|
||||||
return &src, nil
|
return &src, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ func (s Selector) ToOneDriveBackup() (*OneDriveBackup, error) {
|
|||||||
// child properties.
|
// child properties.
|
||||||
// ex: User(u1) automatically cascades to all folders and files owned
|
// ex: User(u1) automatically cascades to all folders and files owned
|
||||||
// by u1.
|
// by u1.
|
||||||
func (s *onedrive) Include(scopes ...[]OneDriveScope) {
|
func (s *oneDrive) Include(scopes ...[]OneDriveScope) {
|
||||||
s.Includes = appendScopes(s.Includes, scopes...)
|
s.Includes = appendScopes(s.Includes, scopes...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ func (s *onedrive) Include(scopes ...[]OneDriveScope) {
|
|||||||
// child properties.
|
// child properties.
|
||||||
// ex: User(u1) automatically cascades to all folders and files owned
|
// ex: User(u1) automatically cascades to all folders and files owned
|
||||||
// by u1.
|
// by u1.
|
||||||
func (s *onedrive) Exclude(scopes ...[]OneDriveScope) {
|
func (s *oneDrive) Exclude(scopes ...[]OneDriveScope) {
|
||||||
s.Excludes = appendScopes(s.Excludes, scopes...)
|
s.Excludes = appendScopes(s.Excludes, scopes...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,16 +98,16 @@ func (s *onedrive) Exclude(scopes ...[]OneDriveScope) {
|
|||||||
// child properties.
|
// child properties.
|
||||||
// ex: User(u1) automatically cascades to all folders and files owned
|
// ex: User(u1) automatically cascades to all folders and files owned
|
||||||
// by u1.
|
// by u1.
|
||||||
func (s *onedrive) Filter(scopes ...[]OneDriveScope) {
|
func (s *oneDrive) Filter(scopes ...[]OneDriveScope) {
|
||||||
s.Filters = appendScopes(s.Filters, scopes...)
|
s.Filters = appendScopes(s.Filters, scopes...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Produces one or more onedrive user scopes.
|
// Produces one or more oneDrive user scopes.
|
||||||
// One scope is created per user entry.
|
// One scope is created per user entry.
|
||||||
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
// If any slice contains selectors.Any, that slice is reduced to [selectors.Any]
|
||||||
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
// If any slice contains selectors.None, that slice is reduced to [selectors.None]
|
||||||
// If any slice is empty, it defaults to [selectors.None]
|
// If any slice is empty, it defaults to [selectors.None]
|
||||||
func (s *onedrive) Users(users []string) []OneDriveScope {
|
func (s *oneDrive) Users(users []string) []OneDriveScope {
|
||||||
users = normalize(users)
|
users = normalize(users)
|
||||||
scopes := []OneDriveScope{}
|
scopes := []OneDriveScope{}
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
@ -116,37 +116,37 @@ func (s *onedrive) Users(users []string) []OneDriveScope {
|
|||||||
return scopes
|
return scopes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scopes retrieves the list of onedriveScopes in the selector.
|
// Scopes retrieves the list of oneDriveScopes in the selector.
|
||||||
func (s *onedrive) Scopes() []OneDriveScope {
|
func (s *oneDrive) Scopes() []OneDriveScope {
|
||||||
return scopes[OneDriveScope](s.Selector)
|
return scopes[OneDriveScope](s.Selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiscreteScopes retrieves the list of onedriveScopes in the selector.
|
// DiscreteScopes retrieves the list of oneDriveScopes in the selector.
|
||||||
// If any Include scope's User category is set to Any, replaces that
|
// If any Include scope's User category is set to Any, replaces that
|
||||||
// scope's value with the list of userIDs instead.
|
// scope's value with the list of userPNs instead.
|
||||||
func (s *onedrive) DiscreteScopes(userIDs []string) []OneDriveScope {
|
func (s *oneDrive) DiscreteScopes(userPNs []string) []OneDriveScope {
|
||||||
return discreteScopes[OneDriveScope](s.Selector, OneDriveUser, userIDs)
|
return discreteScopes[OneDriveScope](s.Selector, OneDriveUser, userPNs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Categories
|
// Categories
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// onedriveCategory enumerates the type of the lowest level
|
// oneDriveCategory enumerates the type of the lowest level
|
||||||
// of data () in a scope.
|
// of data () in a scope.
|
||||||
type onedriveCategory int
|
type oneDriveCategory int
|
||||||
|
|
||||||
// interface compliance checks
|
// interface compliance checks
|
||||||
var _ categorizer = OneDriveCategoryUnknown
|
var _ categorizer = OneDriveCategoryUnknown
|
||||||
|
|
||||||
//go:generate go run golang.org/x/tools/cmd/stringer -type=onedriveCategory
|
//go:generate go run golang.org/x/tools/cmd/stringer -type=oneDriveCategory
|
||||||
const (
|
const (
|
||||||
OneDriveCategoryUnknown onedriveCategory = iota
|
OneDriveCategoryUnknown oneDriveCategory = iota
|
||||||
// types of data identified by OneDrive
|
// types of data identified by OneDrive
|
||||||
OneDriveUser
|
OneDriveUser
|
||||||
)
|
)
|
||||||
|
|
||||||
func onedriveCatAtoI(s string) onedriveCategory {
|
func oneDriveCatAtoI(s string) oneDriveCategory {
|
||||||
switch s {
|
switch s {
|
||||||
// data types
|
// data types
|
||||||
case OneDriveUser.String():
|
case OneDriveUser.String():
|
||||||
@ -169,30 +169,30 @@ var oneDrivePathSet = map[categorizer][]categorizer{
|
|||||||
// (ex: Unknown), the receiver itself is returned.
|
// (ex: Unknown), the receiver itself is returned.
|
||||||
// Ex: ServiceTypeFolder.leafCat() => ServiceTypeItem
|
// Ex: ServiceTypeFolder.leafCat() => ServiceTypeItem
|
||||||
// Ex: ServiceUser.leafCat() => ServiceUser
|
// Ex: ServiceUser.leafCat() => ServiceUser
|
||||||
func (c onedriveCategory) leafCat() categorizer {
|
func (c oneDriveCategory) leafCat() categorizer {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// rootCat returns the root category type.
|
// rootCat returns the root category type.
|
||||||
func (c onedriveCategory) rootCat() categorizer {
|
func (c oneDriveCategory) rootCat() categorizer {
|
||||||
return OneDriveUser
|
return OneDriveUser
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknownCat returns the unknown category type.
|
// unknownCat returns the unknown category type.
|
||||||
func (c onedriveCategory) unknownCat() categorizer {
|
func (c oneDriveCategory) unknownCat() categorizer {
|
||||||
return OneDriveCategoryUnknown
|
return OneDriveCategoryUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
// pathValues transforms a path to a map of identified properties.
|
// pathValues transforms a path to a map of identified properties.
|
||||||
// TODO: this should use service-specific funcs in the Paths pkg. Instead of
|
// TODO: this should use service-specific funcs in the Paths pkg. Instead of
|
||||||
// peeking at the path directly, the caller should compare against values like
|
// peeking at the path directly, the caller should compare against values like
|
||||||
// path.UserID() and path.Folders().
|
// path.UserPN() and path.Folders().
|
||||||
//
|
//
|
||||||
// Malformed (ie, short len) paths will return incomplete results.
|
// Malformed (ie, short len) paths will return incomplete results.
|
||||||
// Example:
|
// Example:
|
||||||
// [tenantID, userID, "files", folder, fileID]
|
// [tenantID, userPN, "files", folder, fileID]
|
||||||
// => {odUser: userID, odFolder: folder, odFileID: fileID}
|
// => {odUser: userPN, odFolder: folder, odFileID: fileID}
|
||||||
func (c onedriveCategory) pathValues(path []string) map[categorizer]string {
|
func (c oneDriveCategory) pathValues(path []string) map[categorizer]string {
|
||||||
m := map[categorizer]string{}
|
m := map[categorizer]string{}
|
||||||
if len(path) < 2 {
|
if len(path) < 2 {
|
||||||
return m
|
return m
|
||||||
@ -211,7 +211,7 @@ func (c onedriveCategory) pathValues(path []string) map[categorizer]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pathKeys returns the path keys recognized by the receiver's leaf type.
|
// pathKeys returns the path keys recognized by the receiver's leaf type.
|
||||||
func (c onedriveCategory) pathKeys() []categorizer {
|
func (c oneDriveCategory) pathKeys() []categorizer {
|
||||||
return oneDrivePathSet[c.leafCat()]
|
return oneDrivePathSet[c.leafCat()]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,8 +227,8 @@ type OneDriveScope scope
|
|||||||
var _ scoper = &OneDriveScope{}
|
var _ scoper = &OneDriveScope{}
|
||||||
|
|
||||||
// Category describes the type of the data in scope.
|
// Category describes the type of the data in scope.
|
||||||
func (s OneDriveScope) Category() onedriveCategory {
|
func (s OneDriveScope) Category() oneDriveCategory {
|
||||||
return onedriveCatAtoI(s[scopeKeyCategory])
|
return oneDriveCatAtoI(s[scopeKeyCategory])
|
||||||
}
|
}
|
||||||
|
|
||||||
// categorizer type is a generic wrapper around Category.
|
// categorizer type is a generic wrapper around Category.
|
||||||
@ -239,8 +239,8 @@ func (s OneDriveScope) categorizer() categorizer {
|
|||||||
|
|
||||||
// FilterCategory returns the category enum of the scope filter.
|
// FilterCategory returns the category enum of the scope filter.
|
||||||
// If the scope is not a filter type, returns OneDriveUnknownCategory.
|
// If the scope is not a filter type, returns OneDriveUnknownCategory.
|
||||||
func (s OneDriveScope) FilterCategory() onedriveCategory {
|
func (s OneDriveScope) FilterCategory() oneDriveCategory {
|
||||||
return onedriveCatAtoI(s[scopeKeyInfoFilter])
|
return oneDriveCatAtoI(s[scopeKeyInfoFilter])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Granularity describes the granularity (directory || item)
|
// Granularity describes the granularity (directory || item)
|
||||||
@ -253,31 +253,31 @@ func (s OneDriveScope) Granularity() string {
|
|||||||
// certain category of data.
|
// certain category of data.
|
||||||
// Ex: to check if the scope includes file data:
|
// Ex: to check if the scope includes file data:
|
||||||
// s.IncludesCategory(selector.OneDriveFile)
|
// s.IncludesCategory(selector.OneDriveFile)
|
||||||
func (s OneDriveScope) IncludesCategory(cat onedriveCategory) bool {
|
func (s OneDriveScope) IncludesCategory(cat oneDriveCategory) bool {
|
||||||
return categoryMatches(s.Category(), cat)
|
return categoryMatches(s.Category(), cat)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains returns true if the category is included in the scope's
|
// Contains returns true if the category is included in the scope's
|
||||||
// data type, and the target string is included in the scope.
|
// data type, and the target string is included in the scope.
|
||||||
func (s OneDriveScope) Contains(cat onedriveCategory, target string) bool {
|
func (s OneDriveScope) Contains(cat oneDriveCategory, target string) bool {
|
||||||
return contains(s, cat, target)
|
return contains(s, cat, target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if the category is included in the scope's data type,
|
// returns true if the category is included in the scope's data type,
|
||||||
// and the value is set to Any().
|
// and the value is set to Any().
|
||||||
func (s OneDriveScope) IsAny(cat onedriveCategory) bool {
|
func (s OneDriveScope) IsAny(cat oneDriveCategory) bool {
|
||||||
return isAnyTarget(s, cat)
|
return isAnyTarget(s, cat)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the data category in the scope. If the scope
|
// Get returns the data category in the scope. If the scope
|
||||||
// contains all data types for a user, it'll return the
|
// contains all data types for a user, it'll return the
|
||||||
// OneDriveUser category.
|
// OneDriveUser category.
|
||||||
func (s OneDriveScope) Get(cat onedriveCategory) []string {
|
func (s OneDriveScope) Get(cat oneDriveCategory) []string {
|
||||||
return getCatValue(s, cat)
|
return getCatValue(s, cat)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets a value by category to the scope. Only intended for internal use.
|
// sets a value by category to the scope. Only intended for internal use.
|
||||||
// func (s OneDriveScope) set(cat onedriveCategory, v string) OneDriveScope {
|
// func (s OneDriveScope) set(cat oneDriveCategory, v string) OneDriveScope {
|
||||||
// return set(s, cat, v)
|
// return set(s, cat, v)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -286,19 +286,19 @@ func (s OneDriveScope) setDefaults() {
|
|||||||
// no-op while no child scope types below user are identified
|
// no-op while no child scope types below user are identified
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchesEntry returns true if either the path or the info in the onedriveEntry matches the scope details.
|
// matchesEntry returns true if either the path or the info in the oneDriveEntry matches the scope details.
|
||||||
func (s OneDriveScope) matchesEntry(
|
func (s OneDriveScope) matchesEntry(
|
||||||
cat categorizer,
|
cat categorizer,
|
||||||
pathValues map[categorizer]string,
|
pathValues map[categorizer]string,
|
||||||
entry details.DetailsEntry,
|
entry details.DetailsEntry,
|
||||||
) bool {
|
) bool {
|
||||||
// matchesPathValues can be handled generically, thanks to SCIENCE.
|
// matchesPathValues can be handled generically, thanks to SCIENCE.
|
||||||
return matchesPathValues(s, cat.(onedriveCategory), pathValues) || s.matchesInfo(entry.Onedrive)
|
return matchesPathValues(s, cat.(oneDriveCategory), pathValues) || s.matchesInfo(entry.OneDrive)
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchesInfo handles the standard behavior when comparing a scope and an onedriveInfo
|
// matchesInfo handles the standard behavior when comparing a scope and an oneDriveInfo
|
||||||
// returns true if the scope and info match for the provided category.
|
// returns true if the scope and info match for the provided category.
|
||||||
func (s OneDriveScope) matchesInfo(info *details.OnedriveInfo) bool {
|
func (s OneDriveScope) matchesInfo(info *details.OneDriveInfo) bool {
|
||||||
// we need values to match against
|
// we need values to match against
|
||||||
if info == nil {
|
if info == nil {
|
||||||
return false
|
return false
|
||||||
@ -318,7 +318,7 @@ func (s OneDriveScope) matchesInfo(info *details.OnedriveInfo) bool {
|
|||||||
// any of the targets for a given info filter may succeed.
|
// any of the targets for a given info filter may succeed.
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
switch filterCat {
|
switch filterCat {
|
||||||
// TODO: populate onedrive filter checks
|
// TODO: populate oneDrive filter checks
|
||||||
default:
|
default:
|
||||||
return target != NoneTgt
|
return target != NoneTgt
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,22 +8,22 @@ import (
|
|||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OnedriveSourceSuite struct {
|
type OneDriveSelectorSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOnedriveSourceSuite(t *testing.T) {
|
func TestOneDriveSelectorSuite(t *testing.T) {
|
||||||
suite.Run(t, new(OnedriveSourceSuite))
|
suite.Run(t, new(OneDriveSelectorSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveSourceSuite) TestNewOnedriveBackup() {
|
func (suite *OneDriveSelectorSuite) TestNewOneDriveBackup() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
ob := NewOneDriveBackup()
|
ob := NewOneDriveBackup()
|
||||||
assert.Equal(t, ob.Service, ServiceOneDrive)
|
assert.Equal(t, ob.Service, ServiceOneDrive)
|
||||||
assert.NotZero(t, ob.Scopes())
|
assert.NotZero(t, ob.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveSourceSuite) TestToOnedriveBackup() {
|
func (suite *OneDriveSelectorSuite) TestToOneDriveBackup() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
ob := NewOneDriveBackup()
|
ob := NewOneDriveBackup()
|
||||||
s := ob.Selector
|
s := ob.Selector
|
||||||
@ -33,7 +33,7 @@ func (suite *OnedriveSourceSuite) TestToOnedriveBackup() {
|
|||||||
assert.NotZero(t, ob.Scopes())
|
assert.NotZero(t, ob.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveSourceSuite) TestOnedriveBackup_DiscreteScopes() {
|
func (suite *OneDriveSelectorSuite) TestOneDriveBackup_DiscreteScopes() {
|
||||||
usrs := []string{"u1", "u2"}
|
usrs := []string{"u1", "u2"}
|
||||||
table := []struct {
|
table := []struct {
|
||||||
name string
|
name string
|
||||||
@ -74,7 +74,7 @@ func (suite *OnedriveSourceSuite) TestOnedriveBackup_DiscreteScopes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveSourceSuite) TestOnedriveSelector_Users() {
|
func (suite *OneDriveSelectorSuite) TestOneDriveSelector_Users() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewOneDriveBackup()
|
sel := NewOneDriveBackup()
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ func (suite *OnedriveSourceSuite) TestOnedriveSelector_Users() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveSourceSuite) TestOneDriveSelector_Include_Users() {
|
func (suite *OneDriveSelectorSuite) TestOneDriveSelector_Include_Users() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewOneDriveBackup()
|
sel := NewOneDriveBackup()
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ func (suite *OnedriveSourceSuite) TestOneDriveSelector_Include_Users() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *OnedriveSourceSuite) TestOneDriveSelector_Exclude_Users() {
|
func (suite *OneDriveSelectorSuite) TestOneDriveSelector_Exclude_Users() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
sel := NewOneDriveBackup()
|
sel := NewOneDriveBackup()
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=onedriveCategory"; DO NOT EDIT.
|
// Code generated by "stringer -type=oneDriveCategory"; DO NOT EDIT.
|
||||||
|
|
||||||
package selectors
|
package selectors
|
||||||
|
|
||||||
@ -12,13 +12,13 @@ func _() {
|
|||||||
_ = x[OneDriveUser-1]
|
_ = x[OneDriveUser-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _onedriveCategory_name = "OneDriveCategoryUnknownOneDriveUser"
|
const _oneDriveCategory_name = "OneDriveCategoryUnknownOneDriveUser"
|
||||||
|
|
||||||
var _onedriveCategory_index = [...]uint8{0, 23, 35}
|
var _oneDriveCategory_index = [...]uint8{0, 23, 35}
|
||||||
|
|
||||||
func (i onedriveCategory) String() string {
|
func (i oneDriveCategory) String() string {
|
||||||
if i < 0 || i >= onedriveCategory(len(_onedriveCategory_index)-1) {
|
if i < 0 || i >= oneDriveCategory(len(_oneDriveCategory_index)-1) {
|
||||||
return "onedriveCategory(" + strconv.FormatInt(int64(i), 10) + ")"
|
return "oneDriveCategory(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||||
}
|
}
|
||||||
return _onedriveCategory_name[_onedriveCategory_index[i]:_onedriveCategory_index[i+1]]
|
return _oneDriveCategory_name[_oneDriveCategory_index[i]:_oneDriveCategory_index[i+1]]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,11 +10,12 @@ func _() {
|
|||||||
var x [1]struct{}
|
var x [1]struct{}
|
||||||
_ = x[ServiceUnknown-0]
|
_ = x[ServiceUnknown-0]
|
||||||
_ = x[ServiceExchange-1]
|
_ = x[ServiceExchange-1]
|
||||||
|
_ = x[ServiceOneDrive-2]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _service_name = "Unknown ServiceExchange"
|
const _service_name = "Unknown ServiceExchangeOneDrive"
|
||||||
|
|
||||||
var _service_index = [...]uint8{0, 15, 23}
|
var _service_index = [...]uint8{0, 15, 23, 31}
|
||||||
|
|
||||||
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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user