CLI: SharePoint.Libraries selector expansion (#2679)
<!-- Insert PR description--> Selector expansion for filters includes the following: - time flags for details filtering - testing --- #### Does this PR need a docs update or release note? - [x] ✅ Yes, it's included #### Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * related to #2602<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [x] ⚡ Unit test
This commit is contained in:
parent
d1404626f1
commit
9cfaf3c140
@ -63,11 +63,6 @@ corso backup details onedrive --backup 1234abcd-12ab-cd34-56de-1234abcd \
|
|||||||
var (
|
var (
|
||||||
folderPaths []string
|
folderPaths []string
|
||||||
fileNames []string
|
fileNames []string
|
||||||
|
|
||||||
fileCreatedAfter string
|
|
||||||
fileCreatedBefore string
|
|
||||||
fileModifiedAfter string
|
|
||||||
fileModifiedBefore string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// called by backup.go to map subcommands to provider-specific handling.
|
// called by backup.go to map subcommands to provider-specific handling.
|
||||||
@ -125,20 +120,20 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command {
|
|||||||
// onedrive info flags
|
// onedrive info flags
|
||||||
|
|
||||||
fs.StringVar(
|
fs.StringVar(
|
||||||
&fileCreatedAfter,
|
&utils.FileCreatedAfter,
|
||||||
utils.FileCreatedAfterFN, "",
|
utils.FileCreatedAfterFN, "",
|
||||||
"Select backup details for files created after this datetime.")
|
"Select backup details for files created after this datetime.")
|
||||||
fs.StringVar(
|
fs.StringVar(
|
||||||
&fileCreatedBefore,
|
&utils.FileCreatedBefore,
|
||||||
utils.FileCreatedBeforeFN, "",
|
utils.FileCreatedBeforeFN, "",
|
||||||
"Select backup details for files created before this datetime.")
|
"Select backup details for files created before this datetime.")
|
||||||
|
|
||||||
fs.StringVar(
|
fs.StringVar(
|
||||||
&fileModifiedAfter,
|
&utils.FileModifiedAfter,
|
||||||
utils.FileModifiedAfterFN, "",
|
utils.FileModifiedAfterFN, "",
|
||||||
"Select backup details for files modified after this datetime.")
|
"Select backup details for files modified after this datetime.")
|
||||||
fs.StringVar(
|
fs.StringVar(
|
||||||
&fileModifiedBefore,
|
&utils.FileModifiedBefore,
|
||||||
utils.FileModifiedBeforeFN, "",
|
utils.FileModifiedBeforeFN, "",
|
||||||
"Select backup details for files modified before this datetime.")
|
"Select backup details for files modified before this datetime.")
|
||||||
|
|
||||||
@ -361,12 +356,12 @@ func detailsOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
opts := utils.OneDriveOpts{
|
opts := utils.OneDriveOpts{
|
||||||
Users: user,
|
Users: user,
|
||||||
Paths: folderPaths,
|
|
||||||
Names: fileNames,
|
Names: fileNames,
|
||||||
FileCreatedAfter: fileCreatedAfter,
|
Paths: folderPaths,
|
||||||
FileCreatedBefore: fileCreatedBefore,
|
FileCreatedAfter: utils.FileCreatedAfter,
|
||||||
FileModifiedAfter: fileModifiedAfter,
|
FileCreatedBefore: utils.FileCreatedBefore,
|
||||||
FileModifiedBefore: fileModifiedBefore,
|
FileModifiedAfter: utils.FileModifiedAfter,
|
||||||
|
FileModifiedBefore: utils.FileModifiedBefore,
|
||||||
|
|
||||||
Populated: utils.GetPopulatedFlags(cmd),
|
Populated: utils.GetPopulatedFlags(cmd),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,11 @@ corso backup delete sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd`
|
|||||||
|
|
||||||
sharePointServiceCommandDetailsExamples = `# Explore <site>'s files from backup 1234abcd-12ab-cd34-56de-1234abcd
|
sharePointServiceCommandDetailsExamples = `# Explore <site>'s files from backup 1234abcd-12ab-cd34-56de-1234abcd
|
||||||
|
|
||||||
corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd --site <site_id>`
|
corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd --site <site_id>
|
||||||
|
# Find all site files that were created before a certain date.
|
||||||
|
corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \
|
||||||
|
--web-url https://example.com --file-created-before 2015-01-01T00:00:00
|
||||||
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
// called by backup.go to map subcommands to provider-specific handling.
|
// called by backup.go to map subcommands to provider-specific handling.
|
||||||
@ -152,12 +156,26 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
|||||||
"Select backup data by file name; accepts '"+utils.Wildcard+"' to select all pages within the site.",
|
"Select backup data by file name; accepts '"+utils.Wildcard+"' to select all pages within the site.",
|
||||||
)
|
)
|
||||||
|
|
||||||
// info flags
|
// sharepoint info flags
|
||||||
|
|
||||||
// fs.StringVar(
|
fs.StringVar(
|
||||||
// &fileCreatedAfter,
|
&utils.FileCreatedAfter,
|
||||||
// utils.FileCreatedAfterFN, "",
|
utils.FileCreatedAfterFN, "",
|
||||||
// "Select backup details for items created after this datetime.")
|
"Select backup details for items created after this datetime.")
|
||||||
|
|
||||||
|
fs.StringVar(
|
||||||
|
&utils.FileCreatedBefore,
|
||||||
|
utils.FileCreatedBeforeFN, "",
|
||||||
|
"Select backup details for files created before this datetime.")
|
||||||
|
|
||||||
|
fs.StringVar(
|
||||||
|
&utils.FileModifiedAfter,
|
||||||
|
utils.FileModifiedAfterFN, "",
|
||||||
|
"Select backup details for files modified after this datetime.")
|
||||||
|
fs.StringVar(
|
||||||
|
&utils.FileModifiedBefore,
|
||||||
|
utils.FileModifiedBeforeFN, "",
|
||||||
|
"Select backup details for files modified before this datetime.")
|
||||||
|
|
||||||
case deleteCommand:
|
case deleteCommand:
|
||||||
c, fs = utils.AddCommand(cmd, sharePointDeleteCmd(), utils.MarkPreReleaseCommand())
|
c, fs = utils.AddCommand(cmd, sharePointDeleteCmd(), utils.MarkPreReleaseCommand())
|
||||||
@ -491,12 +509,15 @@ func detailsSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
|
|
||||||
opts := utils.SharePointOpts{
|
opts := utils.SharePointOpts{
|
||||||
LibraryItems: libraryItems,
|
LibraryItems: libraryItems,
|
||||||
LibraryPaths: libraryPaths,
|
LibraryPaths: libraryPaths,
|
||||||
Sites: site,
|
Sites: site,
|
||||||
WebURLs: weburl,
|
WebURLs: weburl,
|
||||||
|
FileCreatedAfter: utils.FileCreatedAfter,
|
||||||
Populated: utils.GetPopulatedFlags(cmd),
|
FileCreatedBefore: utils.FileCreatedBefore,
|
||||||
|
FileModifiedAfter: utils.FileModifiedAfter,
|
||||||
|
FileModifiedBefore: utils.FileModifiedBefore,
|
||||||
|
Populated: utils.GetPopulatedFlags(cmd),
|
||||||
}
|
}
|
||||||
|
|
||||||
ds, err := runDetailsSharePointCmd(ctx, r, backupID, opts, ctrlOpts.SkipReduce)
|
ds, err := runDetailsSharePointCmd(ctx, r, backupID, opts, ctrlOpts.SkipReduce)
|
||||||
|
|||||||
@ -133,12 +133,12 @@ func restoreOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
opts := utils.OneDriveOpts{
|
opts := utils.OneDriveOpts{
|
||||||
Users: user,
|
Users: user,
|
||||||
Paths: folderPaths,
|
|
||||||
Names: fileNames,
|
Names: fileNames,
|
||||||
FileCreatedAfter: fileCreatedAfter,
|
Paths: folderPaths,
|
||||||
FileCreatedBefore: fileCreatedBefore,
|
FileCreatedAfter: utils.FileCreatedAfter,
|
||||||
FileModifiedAfter: fileModifiedAfter,
|
FileCreatedBefore: utils.FileCreatedBefore,
|
||||||
FileModifiedBefore: fileModifiedBefore,
|
FileModifiedAfter: utils.FileModifiedAfter,
|
||||||
|
FileModifiedBefore: utils.FileModifiedBefore,
|
||||||
|
|
||||||
Populated: utils.GetPopulatedFlags(cmd),
|
Populated: utils.GetPopulatedFlags(cmd),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,17 +141,19 @@ func restoreSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
opts := utils.SharePointOpts{
|
opts := utils.SharePointOpts{
|
||||||
ListItems: listItems,
|
LibraryItems: libraryItems,
|
||||||
ListPaths: listPaths,
|
LibraryPaths: libraryPaths,
|
||||||
LibraryItems: libraryItems,
|
ListItems: listItems,
|
||||||
LibraryPaths: libraryPaths,
|
ListPaths: listPaths,
|
||||||
PageFolders: pageFolders,
|
PageFolders: pageFolders,
|
||||||
Pages: pages,
|
Pages: pages,
|
||||||
Sites: site,
|
Sites: site,
|
||||||
WebURLs: weburl,
|
WebURLs: weburl,
|
||||||
// FileCreatedAfter: fileCreatedAfter,
|
FileCreatedAfter: utils.FileCreatedAfter,
|
||||||
|
FileCreatedBefore: utils.FileCreatedBefore,
|
||||||
Populated: utils.GetPopulatedFlags(cmd),
|
FileModifiedAfter: utils.FileModifiedAfter,
|
||||||
|
FileModifiedBefore: utils.FileModifiedBefore,
|
||||||
|
Populated: utils.GetPopulatedFlags(cmd),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.ValidateSharePointRestoreFlags(backupID, opts); err != nil {
|
if err := utils.ValidateSharePointRestoreFlags(backupID, opts); err != nil {
|
||||||
|
|||||||
@ -10,6 +10,20 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ==============================================
|
||||||
|
// Folder Object flags
|
||||||
|
// These options are flags for indicating
|
||||||
|
// that a time-based filter should be used for
|
||||||
|
// within returning objects for details.
|
||||||
|
// Used by: OneDrive, SharePoint
|
||||||
|
// ================================================
|
||||||
|
var (
|
||||||
|
FileCreatedAfter string
|
||||||
|
FileCreatedBefore string
|
||||||
|
FileModifiedAfter string
|
||||||
|
FileModifiedBefore string
|
||||||
|
)
|
||||||
|
|
||||||
type PopulatedFlags map[string]struct{}
|
type PopulatedFlags map[string]struct{}
|
||||||
|
|
||||||
func (fs PopulatedFlags) populate(pf *pflag.Flag) {
|
func (fs PopulatedFlags) populate(pf *pflag.Flag) {
|
||||||
|
|||||||
@ -7,14 +7,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FileFN = "file"
|
FileFN = "file"
|
||||||
FolderFN = "folder"
|
FolderFN = "folder"
|
||||||
NamesFN = "name"
|
NamesFN = "name"
|
||||||
PathsFN = "path"
|
PathsFN = "path"
|
||||||
FileCreatedAfterFN = "file-created-after"
|
|
||||||
FileCreatedBeforeFN = "file-created-before"
|
|
||||||
FileModifiedAfterFN = "file-modified-after"
|
|
||||||
FileModifiedBeforeFN = "file-modified-before"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OneDriveOpts struct {
|
type OneDriveOpts struct {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
)
|
)
|
||||||
@ -17,14 +18,18 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type SharePointOpts struct {
|
type SharePointOpts struct {
|
||||||
LibraryItems []string
|
LibraryItems []string
|
||||||
LibraryPaths []string
|
LibraryPaths []string
|
||||||
ListItems []string
|
ListItems []string
|
||||||
ListPaths []string
|
ListPaths []string
|
||||||
PageFolders []string
|
PageFolders []string
|
||||||
Pages []string
|
Pages []string
|
||||||
Sites []string
|
Sites []string
|
||||||
WebURLs []string
|
WebURLs []string
|
||||||
|
FileCreatedAfter string
|
||||||
|
FileCreatedBefore string
|
||||||
|
FileModifiedAfter string
|
||||||
|
FileModifiedBefore string
|
||||||
|
|
||||||
Populated PopulatedFlags
|
Populated PopulatedFlags
|
||||||
}
|
}
|
||||||
@ -35,9 +40,22 @@ func ValidateSharePointRestoreFlags(backupID string, opts SharePointOpts) error
|
|||||||
return errors.New("a backup ID is required")
|
return errors.New("a backup ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
// if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) {
|
if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) {
|
||||||
// return errors.New("invalid time format for created-after")
|
fmt.Printf("What was I sent: %v\n", opts.FileCreatedAfter)
|
||||||
// }
|
return errors.New("invalid time format for " + FileCreatedAfterFN)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := opts.Populated[FileCreatedBeforeFN]; ok && !IsValidTimeFormat(opts.FileCreatedBefore) {
|
||||||
|
return errors.New("invalid time format for " + FileCreatedBeforeFN)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := opts.Populated[FileModifiedAfterFN]; ok && !IsValidTimeFormat(opts.FileModifiedAfter) {
|
||||||
|
return errors.New("invalid time format for " + FileModifiedAfterFN)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := opts.Populated[FileModifiedBeforeFN]; ok && !IsValidTimeFormat(opts.FileModifiedBefore) {
|
||||||
|
return errors.New("invalid time format for " + FileModifiedBeforeFN)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -149,5 +167,8 @@ func FilterSharePointRestoreInfoSelectors(
|
|||||||
sel *selectors.SharePointRestore,
|
sel *selectors.SharePointRestore,
|
||||||
opts SharePointOpts,
|
opts SharePointOpts,
|
||||||
) {
|
) {
|
||||||
// AddSharePointFilter(sel, opts.FileCreatedAfter, sel.CreatedAfter)
|
AddSharePointFilter(sel, opts.FileCreatedAfter, sel.CreatedAfter)
|
||||||
|
AddSharePointFilter(sel, opts.FileCreatedBefore, sel.CreatedBefore)
|
||||||
|
AddSharePointFilter(sel, opts.FileModifiedAfter, sel.ModifiedAfter)
|
||||||
|
AddSharePointFilter(sel, opts.FileModifiedBefore, sel.ModifiedBefore)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,14 @@ import (
|
|||||||
|
|
||||||
// common flag names
|
// common flag names
|
||||||
const (
|
const (
|
||||||
BackupFN = "backup"
|
BackupFN = "backup"
|
||||||
DataFN = "data"
|
DataFN = "data"
|
||||||
SiteFN = "site"
|
SiteFN = "site"
|
||||||
UserFN = "user"
|
UserFN = "user"
|
||||||
|
FileCreatedAfterFN = "file-created-after"
|
||||||
|
FileCreatedBeforeFN = "file-created-before"
|
||||||
|
FileModifiedAfterFN = "file-modified-after"
|
||||||
|
FileModifiedBeforeFN = "file-modified-before"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@ -3,8 +3,10 @@ package selectors
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
|
"github.com/alcionai/corso/src/pkg/filters"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -333,6 +335,46 @@ func (s *sharePoint) PageItems(pages, items []string, opts ...option) []SharePoi
|
|||||||
// -------------------
|
// -------------------
|
||||||
// Filter Factories
|
// Filter Factories
|
||||||
|
|
||||||
|
func (s *sharePoint) CreatedAfter(timeStrings string) []SharePointScope {
|
||||||
|
return []SharePointScope{
|
||||||
|
makeFilterScope[SharePointScope](
|
||||||
|
SharePointLibraryItem,
|
||||||
|
FileFilterCreatedAfter,
|
||||||
|
[]string{timeStrings},
|
||||||
|
wrapFilter(filters.Less)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *sharePoint) CreatedBefore(timeStrings string) []SharePointScope {
|
||||||
|
return []SharePointScope{
|
||||||
|
makeFilterScope[SharePointScope](
|
||||||
|
SharePointLibraryItem,
|
||||||
|
FileFilterCreatedBefore,
|
||||||
|
[]string{timeStrings},
|
||||||
|
wrapFilter(filters.Greater)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *sharePoint) ModifiedAfter(timeStrings string) []SharePointScope {
|
||||||
|
return []SharePointScope{
|
||||||
|
makeFilterScope[SharePointScope](
|
||||||
|
SharePointLibraryItem,
|
||||||
|
FileFilterModifiedAfter,
|
||||||
|
[]string{timeStrings},
|
||||||
|
wrapFilter(filters.Less)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *sharePoint) ModifiedBefore(timeStrings string) []SharePointScope {
|
||||||
|
return []SharePointScope{
|
||||||
|
makeFilterScope[SharePointScope](
|
||||||
|
SharePointLibraryItem,
|
||||||
|
FileFilterModifiedBefore,
|
||||||
|
[]string{timeStrings},
|
||||||
|
wrapFilter(filters.Greater)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Categories
|
// Categories
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -358,6 +400,10 @@ const (
|
|||||||
SharePointPage sharePointCategory = "SharePointPage"
|
SharePointPage sharePointCategory = "SharePointPage"
|
||||||
|
|
||||||
// filterable topics identified by SharePoint
|
// filterable topics identified by SharePoint
|
||||||
|
SiteFilterCreatedAfter sharePointCategory = "FileFilterCreatedAfter"
|
||||||
|
SiteFilterCreatedBefore sharePointCategory = "FileFilterCreatedBefore"
|
||||||
|
SiteFilterModifiedAfter sharePointCategory = "FileFilterModifiedAfter"
|
||||||
|
SiteFilterModifiedBefore sharePointCategory = "FileFilterModifiedBefore"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sharePointLeafProperties describes common metadata of the leaf categories
|
// sharePointLeafProperties describes common metadata of the leaf categories
|
||||||
@ -391,7 +437,9 @@ func (c sharePointCategory) String() string {
|
|||||||
// Ex: ServiceUser.leafCat() => ServiceUser
|
// Ex: ServiceUser.leafCat() => ServiceUser
|
||||||
func (c sharePointCategory) leafCat() categorizer {
|
func (c sharePointCategory) leafCat() categorizer {
|
||||||
switch c {
|
switch c {
|
||||||
case SharePointLibrary, SharePointLibraryItem:
|
case SharePointLibrary, SharePointLibraryItem,
|
||||||
|
SiteFilterCreatedAfter, SiteFilterCreatedBefore,
|
||||||
|
SiteFilterModifiedAfter, SiteFilterModifiedBefore:
|
||||||
return SharePointLibraryItem
|
return SharePointLibraryItem
|
||||||
case SharePointList, SharePointListItem:
|
case SharePointList, SharePointListItem:
|
||||||
return SharePointListItem
|
return SharePointListItem
|
||||||
@ -600,6 +648,10 @@ func (s SharePointScope) matchesInfo(dii details.ItemInfo) bool {
|
|||||||
switch filterCat {
|
switch filterCat {
|
||||||
case SharePointWebURL:
|
case SharePointWebURL:
|
||||||
i = info.WebURL
|
i = info.WebURL
|
||||||
|
case SiteFilterCreatedAfter, SiteFilterCreatedBefore:
|
||||||
|
i = common.FormatTime(info.Created)
|
||||||
|
case SiteFilterModifiedAfter, SiteFilterModifiedBefore:
|
||||||
|
i = common.FormatTime(info.Modified)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.Matches(filterCat, i)
|
return s.Matches(filterCat, i)
|
||||||
|
|||||||
@ -2,11 +2,13 @@ package selectors
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"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/common"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
@ -363,10 +365,14 @@ func (suite *SharePointSelectorSuite) TestSharePointCategory_PathValues() {
|
|||||||
|
|
||||||
func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
|
func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
|
||||||
var (
|
var (
|
||||||
ods = NewSharePointRestore(nil)
|
ods = NewSharePointRestore(Any())
|
||||||
host = "www.website.com"
|
host = "www.website.com"
|
||||||
pth = "/foo"
|
pth = "/foo"
|
||||||
url = host + pth
|
url = host + pth
|
||||||
|
epoch = time.Time{}
|
||||||
|
now = time.Now()
|
||||||
|
modification = now.Add(15 * time.Minute)
|
||||||
|
future = now.Add(45 * time.Minute)
|
||||||
)
|
)
|
||||||
|
|
||||||
table := []struct {
|
table := []struct {
|
||||||
@ -385,6 +391,19 @@ func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
|
|||||||
{"host does not contain substring", host, ods.WebURL([]string{"website"}), assert.False},
|
{"host does not contain substring", host, ods.WebURL([]string{"website"}), assert.False},
|
||||||
{"url does not suffix substring", url, ods.WebURL([]string{"oo"}), assert.False},
|
{"url does not suffix substring", url, ods.WebURL([]string{"oo"}), assert.False},
|
||||||
{"host mismatch", host, ods.WebURL([]string{"www.google.com"}), assert.False},
|
{"host mismatch", host, ods.WebURL([]string{"www.google.com"}), assert.False},
|
||||||
|
{"file create after the epoch", host, ods.CreatedAfter(common.FormatTime(epoch)), assert.True},
|
||||||
|
{"file create after now", host, ods.CreatedAfter(common.FormatTime(now)), assert.False},
|
||||||
|
{"file create after later", url, ods.CreatedAfter(common.FormatTime(future)), assert.False},
|
||||||
|
{"file create before future", host, ods.CreatedBefore(common.FormatTime(future)), assert.True},
|
||||||
|
{"file create before now", host, ods.CreatedBefore(common.FormatTime(now)), assert.False},
|
||||||
|
{"file create before modification", host, ods.CreatedBefore(common.FormatTime(modification)), assert.True},
|
||||||
|
{"file create before epoch", host, ods.CreatedBefore(common.FormatTime(now)), assert.False},
|
||||||
|
{"file modified after the epoch", host, ods.ModifiedAfter(common.FormatTime(epoch)), assert.True},
|
||||||
|
{"file modified after now", host, ods.ModifiedAfter(common.FormatTime(now)), assert.True},
|
||||||
|
{"file modified after later", host, ods.ModifiedAfter(common.FormatTime(future)), assert.False},
|
||||||
|
{"file modified before future", host, ods.ModifiedBefore(common.FormatTime(future)), assert.True},
|
||||||
|
{"file modified before now", host, ods.ModifiedBefore(common.FormatTime(now)), assert.False},
|
||||||
|
{"file modified before epoch", host, ods.ModifiedBefore(common.FormatTime(now)), assert.False},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
@ -394,6 +413,8 @@ func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
|
|||||||
SharePoint: &details.SharePointInfo{
|
SharePoint: &details.SharePointInfo{
|
||||||
ItemType: details.SharePointItem,
|
ItemType: details.SharePointItem,
|
||||||
WebURL: test.infoURL,
|
WebURL: test.infoURL,
|
||||||
|
Created: now,
|
||||||
|
Modified: modification,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user