rename DetailsEntry to Entry to avoid stuttering (#3265)
#### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
c3cc40176e
commit
3b9d2841d4
50
src/cli/utils/testdata/opts.go
vendored
50
src/cli/utils/testdata/opts.go
vendored
@ -21,7 +21,7 @@ type ExchangeOptionsTest struct {
|
||||
Name string
|
||||
Opts utils.ExchangeOpts
|
||||
BackupGetter *MockBackupGetter
|
||||
Expected []details.DetailsEntry
|
||||
Expected []details.Entry
|
||||
}
|
||||
|
||||
var (
|
||||
@ -150,7 +150,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "EmailsFolderWithSlashPrefixMatch",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.ExchangeEmailItems[1],
|
||||
testdata.ExchangeEmailItems[2],
|
||||
},
|
||||
@ -160,7 +160,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "EmailsFolderWithSlashPrefixMatchTrailingSlash",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.ExchangeEmailItems[1],
|
||||
testdata.ExchangeEmailItems[2],
|
||||
},
|
||||
@ -170,7 +170,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "EmailsBySubject",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.ExchangeEmailItems[0],
|
||||
testdata.ExchangeEmailItems[1],
|
||||
},
|
||||
@ -183,7 +183,7 @@ var (
|
||||
Expected: append(
|
||||
append(
|
||||
append(
|
||||
[]details.DetailsEntry{},
|
||||
[]details.Entry{},
|
||||
testdata.ExchangeEmailItems...,
|
||||
),
|
||||
testdata.ExchangeContactsItems...,
|
||||
@ -193,28 +193,28 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "MailReceivedTime",
|
||||
Expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
Expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
Opts: utils.ExchangeOpts{
|
||||
EmailReceivedBefore: common.FormatTime(testdata.Time1.Add(time.Second)),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "MailItemRef",
|
||||
Expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
Expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
Opts: utils.ExchangeOpts{
|
||||
Email: []string{testdata.ExchangeEmailItems[0].ItemRef},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "MailShortRef",
|
||||
Expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
Expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
Opts: utils.ExchangeOpts{
|
||||
Email: []string{testdata.ExchangeEmailItemPath1.RR.ShortRef()},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "MultipleMailShortRef",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.ExchangeEmailItems[0],
|
||||
testdata.ExchangeEmailItems[1],
|
||||
},
|
||||
@ -227,7 +227,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "AllEventsAndMailWithSubject",
|
||||
Expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
Expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
Opts: utils.ExchangeOpts{
|
||||
EmailSubject: "foo",
|
||||
Event: selectors.Any(),
|
||||
@ -235,7 +235,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "EventsAndMailWithSubject",
|
||||
Expected: []details.DetailsEntry{},
|
||||
Expected: []details.Entry{},
|
||||
Opts: utils.ExchangeOpts{
|
||||
EmailSubject: "foo",
|
||||
EventSubject: "foo",
|
||||
@ -243,7 +243,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "EventsAndMailByShortRef",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.ExchangeEmailItems[0],
|
||||
testdata.ExchangeEventsItems[0],
|
||||
},
|
||||
@ -259,7 +259,7 @@ type OneDriveOptionsTest struct {
|
||||
Name string
|
||||
Opts utils.OneDriveOpts
|
||||
BackupGetter *MockBackupGetter
|
||||
Expected []details.DetailsEntry
|
||||
Expected []details.Entry
|
||||
}
|
||||
|
||||
var (
|
||||
@ -377,14 +377,14 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "FolderRepoRefMatchesNothing",
|
||||
Expected: []details.DetailsEntry{},
|
||||
Expected: []details.Entry{},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FolderPath: []string{testdata.OneDriveFolderPath.RR.Folder(true)},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ShortRef",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.OneDriveItems[0],
|
||||
testdata.OneDriveItems[1],
|
||||
},
|
||||
@ -397,7 +397,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "SingleItem",
|
||||
Expected: []details.DetailsEntry{testdata.OneDriveItems[0]},
|
||||
Expected: []details.Entry{testdata.OneDriveItems[0]},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FileName: []string{
|
||||
testdata.OneDriveItems[0].OneDrive.ItemName,
|
||||
@ -406,7 +406,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "MultipleItems",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.OneDriveItems[0],
|
||||
testdata.OneDriveItems[1],
|
||||
},
|
||||
@ -419,7 +419,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "ItemRefMatchesNothing",
|
||||
Expected: []details.DetailsEntry{},
|
||||
Expected: []details.Entry{},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FileName: []string{
|
||||
testdata.OneDriveItems[0].ItemRef,
|
||||
@ -428,7 +428,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "CreatedBefore",
|
||||
Expected: []details.DetailsEntry{testdata.OneDriveItems[1]},
|
||||
Expected: []details.Entry{testdata.OneDriveItems[1]},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FileCreatedBefore: common.FormatTime(testdata.Time1.Add(time.Second)),
|
||||
},
|
||||
@ -440,7 +440,7 @@ type SharePointOptionsTest struct {
|
||||
Name string
|
||||
Opts utils.SharePointOpts
|
||||
BackupGetter *MockBackupGetter
|
||||
Expected []details.DetailsEntry
|
||||
Expected []details.Entry
|
||||
}
|
||||
|
||||
var (
|
||||
@ -503,14 +503,14 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "FolderRepoRefMatchesNothing",
|
||||
Expected: []details.DetailsEntry{},
|
||||
Expected: []details.Entry{},
|
||||
Opts: utils.SharePointOpts{
|
||||
FolderPath: []string{testdata.SharePointLibraryPath.RR.Folder(true)},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "ShortRef",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.SharePointLibraryItems[0],
|
||||
testdata.SharePointLibraryItems[1],
|
||||
},
|
||||
@ -523,7 +523,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "SingleItem",
|
||||
Expected: []details.DetailsEntry{testdata.SharePointLibraryItems[0]},
|
||||
Expected: []details.Entry{testdata.SharePointLibraryItems[0]},
|
||||
Opts: utils.SharePointOpts{
|
||||
FileName: []string{
|
||||
testdata.SharePointLibraryItems[0].SharePoint.ItemName,
|
||||
@ -532,7 +532,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "MultipleItems",
|
||||
Expected: []details.DetailsEntry{
|
||||
Expected: []details.Entry{
|
||||
testdata.SharePointLibraryItems[0],
|
||||
testdata.SharePointLibraryItems[1],
|
||||
},
|
||||
@ -545,7 +545,7 @@ var (
|
||||
},
|
||||
{
|
||||
Name: "ItemRefMatchesNothing",
|
||||
Expected: []details.DetailsEntry{},
|
||||
Expected: []details.Entry{},
|
||||
Opts: utils.SharePointOpts{
|
||||
FileName: []string{
|
||||
testdata.SharePointLibraryItems[0].ItemRef,
|
||||
|
||||
@ -540,7 +540,7 @@ func matchesReason(reasons []kopia.Reason, p path.Path) bool {
|
||||
// 4. any errors encountered
|
||||
func getNewPathRefs(
|
||||
dataFromBackup kopia.DetailsMergeInfoer,
|
||||
entry *details.DetailsEntry,
|
||||
entry *details.Entry,
|
||||
repoRef path.Path,
|
||||
backupVersion int,
|
||||
) (path.Path, *path.Builder, bool, error) {
|
||||
|
||||
@ -271,10 +271,10 @@ func makeFolderEntry(
|
||||
size int64,
|
||||
modTime time.Time,
|
||||
dt details.ItemType,
|
||||
) *details.DetailsEntry {
|
||||
) *details.Entry {
|
||||
t.Helper()
|
||||
|
||||
return &details.DetailsEntry{
|
||||
return &details.Entry{
|
||||
RepoRef: pb.String(),
|
||||
ShortRef: pb.ShortRef(),
|
||||
ParentRef: pb.Dir().ShortRef(),
|
||||
@ -308,7 +308,7 @@ func makeDetailsEntry(
|
||||
l *path.Builder,
|
||||
size int,
|
||||
updated bool,
|
||||
) *details.DetailsEntry {
|
||||
) *details.Entry {
|
||||
t.Helper()
|
||||
|
||||
var lr string
|
||||
@ -316,7 +316,7 @@ func makeDetailsEntry(
|
||||
lr = l.String()
|
||||
}
|
||||
|
||||
res := &details.DetailsEntry{
|
||||
res := &details.Entry{
|
||||
RepoRef: p.String(),
|
||||
ShortRef: p.ShortRef(),
|
||||
ParentRef: p.ToBuilder().Dir().ShortRef(),
|
||||
@ -718,20 +718,20 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
mdm *mockDetailsMergeInfoer
|
||||
|
||||
errCheck assert.ErrorAssertionFunc
|
||||
expectedEntries []*details.DetailsEntry
|
||||
expectedEntries []*details.Entry
|
||||
}{
|
||||
{
|
||||
name: "NilShortRefsFromPrevBackup",
|
||||
errCheck: assert.NoError,
|
||||
// Use empty slice so we don't error out on nil != empty.
|
||||
expectedEntries: []*details.DetailsEntry{},
|
||||
expectedEntries: []*details.Entry{},
|
||||
},
|
||||
{
|
||||
name: "EmptyShortRefsFromPrevBackup",
|
||||
mdm: newMockDetailsMergeInfoer(),
|
||||
errCheck: assert.NoError,
|
||||
// Use empty slice so we don't error out on nil != empty.
|
||||
expectedEntries: []*details.DetailsEntry{},
|
||||
expectedEntries: []*details.Entry{},
|
||||
},
|
||||
{
|
||||
name: "BackupIDNotFound",
|
||||
@ -800,7 +800,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
@ -836,7 +836,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
@ -866,7 +866,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
{
|
||||
RepoRef: stdpath.Join(
|
||||
append(
|
||||
@ -928,7 +928,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
@ -958,14 +958,14 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
expectedEntries: []*details.DetailsEntry{
|
||||
expectedEntries: []*details.Entry{
|
||||
makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
@ -991,14 +991,14 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
expectedEntries: []*details.DetailsEntry{
|
||||
expectedEntries: []*details.Entry{
|
||||
makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
@ -1024,7 +1024,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
*makeDetailsEntry(suite.T(), itemPath2, locationPath2, 84, false),
|
||||
},
|
||||
@ -1032,7 +1032,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
expectedEntries: []*details.DetailsEntry{
|
||||
expectedEntries: []*details.Entry{
|
||||
makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
@ -1058,14 +1058,14 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
expectedEntries: []*details.DetailsEntry{
|
||||
expectedEntries: []*details.Entry{
|
||||
makeDetailsEntry(suite.T(), itemPath2, locationPath2, 42, true),
|
||||
},
|
||||
},
|
||||
@ -1099,14 +1099,14 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
},
|
||||
backup2.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
// This entry should not be picked due to a mismatch on Reasons.
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 84, false),
|
||||
// This item should be picked.
|
||||
@ -1116,7 +1116,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
expectedEntries: []*details.DetailsEntry{
|
||||
expectedEntries: []*details.Entry{
|
||||
makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
makeDetailsEntry(suite.T(), itemPath3, locationPath3, 37, false),
|
||||
},
|
||||
@ -1150,14 +1150,14 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
populatedDetails: map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
},
|
||||
backup2.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
// This entry should not be picked due to being incomplete.
|
||||
*makeDetailsEntry(suite.T(), itemPath1, locationPath1, 84, false),
|
||||
},
|
||||
@ -1165,7 +1165,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
},
|
||||
},
|
||||
errCheck: assert.NoError,
|
||||
expectedEntries: []*details.DetailsEntry{
|
||||
expectedEntries: []*details.Entry{
|
||||
makeDetailsEntry(suite.T(), itemPath1, locationPath1, 42, false),
|
||||
},
|
||||
},
|
||||
@ -1265,12 +1265,12 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsFolde
|
||||
populatedDetails := map[string]*details.Details{
|
||||
backup1.DetailsID: {
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{*itemDetails},
|
||||
Entries: []details.Entry{*itemDetails},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expectedEntries := []details.DetailsEntry{*itemDetails}
|
||||
expectedEntries := []details.Entry{*itemDetails}
|
||||
|
||||
// update the details
|
||||
itemDetails.Exchange.Modified = now
|
||||
@ -1312,7 +1312,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsFolde
|
||||
// assert.elementsMatch to fail.
|
||||
func compareDeetEntries(
|
||||
t *testing.T,
|
||||
expect, result []details.DetailsEntry,
|
||||
expect, result []details.Entry,
|
||||
) {
|
||||
if !assert.Equal(t, len(expect), len(result), "entry slices should be equal len") {
|
||||
require.ElementsMatch(t, expect, result)
|
||||
@ -1321,8 +1321,8 @@ func compareDeetEntries(
|
||||
var (
|
||||
// repoRef -> modified time
|
||||
eMods = map[string]time.Time{}
|
||||
es = make([]details.DetailsEntry, 0, len(expect))
|
||||
rs = make([]details.DetailsEntry, 0, len(expect))
|
||||
es = make([]details.Entry, 0, len(expect))
|
||||
rs = make([]details.Entry, 0, len(expect))
|
||||
)
|
||||
|
||||
for _, e := range expect {
|
||||
@ -1347,7 +1347,7 @@ func compareDeetEntries(
|
||||
assert.ElementsMatch(t, es, rs)
|
||||
}
|
||||
|
||||
func withoutModified(de details.DetailsEntry) details.DetailsEntry {
|
||||
func withoutModified(de details.Entry) details.Entry {
|
||||
switch {
|
||||
case de.Exchange != nil:
|
||||
de.Exchange.Modified = time.Time{}
|
||||
|
||||
@ -133,7 +133,7 @@ func NewSharePointLocationIDer(
|
||||
|
||||
// DetailsModel describes what was stored in a Backup
|
||||
type DetailsModel struct {
|
||||
Entries []DetailsEntry `json:"entries"`
|
||||
Entries []Entry `json:"entries"`
|
||||
}
|
||||
|
||||
// Print writes the DetailModel Entries to StdOut, in the format
|
||||
@ -194,8 +194,8 @@ func (dm DetailsModel) Paths() []string {
|
||||
// Items returns a slice of *ItemInfo that does not contain any FolderInfo
|
||||
// entries. Required because not all folders in the details are valid resource
|
||||
// paths, and we want to slice out metadata.
|
||||
func (dm DetailsModel) Items() []*DetailsEntry {
|
||||
res := make([]*DetailsEntry, 0, len(dm.Entries))
|
||||
func (dm DetailsModel) Items() []*Entry {
|
||||
res := make([]*Entry, 0, len(dm.Entries))
|
||||
|
||||
for i := 0; i < len(dm.Entries); i++ {
|
||||
ent := dm.Entries[i]
|
||||
@ -213,7 +213,7 @@ func (dm DetailsModel) Items() []*DetailsEntry {
|
||||
// .meta files removed from the entries.
|
||||
func (dm DetailsModel) FilterMetaFiles() DetailsModel {
|
||||
d2 := DetailsModel{
|
||||
Entries: []DetailsEntry{},
|
||||
Entries: []Entry{},
|
||||
}
|
||||
|
||||
for _, ent := range dm.Entries {
|
||||
@ -228,7 +228,7 @@ func (dm DetailsModel) FilterMetaFiles() DetailsModel {
|
||||
// Check if a file is a metadata file. These are used to store
|
||||
// additional data like permissions in case of OneDrive and are not to
|
||||
// be treated as regular files.
|
||||
func (de DetailsEntry) isMetaFile() bool {
|
||||
func (de Entry) isMetaFile() bool {
|
||||
// TODO: Add meta file filtering to SharePoint as well once we add
|
||||
// meta files for SharePoint.
|
||||
return de.ItemInfo.OneDrive != nil && de.ItemInfo.OneDrive.IsMeta
|
||||
@ -241,8 +241,8 @@ func (de DetailsEntry) isMetaFile() bool {
|
||||
// Builder should be used to create a details model.
|
||||
type Builder struct {
|
||||
d Details
|
||||
mu sync.Mutex `json:"-"`
|
||||
knownFolders map[string]DetailsEntry `json:"-"`
|
||||
mu sync.Mutex `json:"-"`
|
||||
knownFolders map[string]Entry `json:"-"`
|
||||
}
|
||||
|
||||
func (b *Builder) Add(
|
||||
@ -276,7 +276,7 @@ func (b *Builder) Add(
|
||||
|
||||
func (b *Builder) addFolderEntries(
|
||||
repoRef, locationRef *path.Builder,
|
||||
entry DetailsEntry,
|
||||
entry Entry,
|
||||
) error {
|
||||
if len(repoRef.Elements()) < len(locationRef.Elements()) {
|
||||
return clues.New("RepoRef shorter than LocationRef").
|
||||
@ -284,7 +284,7 @@ func (b *Builder) addFolderEntries(
|
||||
}
|
||||
|
||||
if b.knownFolders == nil {
|
||||
b.knownFolders = map[string]DetailsEntry{}
|
||||
b.knownFolders = map[string]Entry{}
|
||||
}
|
||||
|
||||
// Need a unique location because we want to have separate folders for
|
||||
@ -317,7 +317,7 @@ func (b *Builder) addFolderEntries(
|
||||
if !ok {
|
||||
loc := uniqueLoc.InDetails().String()
|
||||
|
||||
folder = DetailsEntry{
|
||||
folder = Entry{
|
||||
RepoRef: rr,
|
||||
ShortRef: shortRef,
|
||||
ParentRef: parentRef,
|
||||
@ -380,12 +380,12 @@ func (d *Details) add(
|
||||
locationRef *path.Builder,
|
||||
updated bool,
|
||||
info ItemInfo,
|
||||
) (DetailsEntry, error) {
|
||||
) (Entry, error) {
|
||||
if locationRef == nil {
|
||||
return DetailsEntry{}, clues.New("nil LocationRef").With("repo_ref", repoRef)
|
||||
return Entry{}, clues.New("nil LocationRef").With("repo_ref", repoRef)
|
||||
}
|
||||
|
||||
entry := DetailsEntry{
|
||||
entry := Entry{
|
||||
RepoRef: repoRef.String(),
|
||||
ShortRef: repoRef.ShortRef(),
|
||||
ParentRef: repoRef.ToBuilder().Dir().ShortRef(),
|
||||
@ -457,8 +457,8 @@ func withoutMetadataSuffix(id string) string {
|
||||
// Entry
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// DetailsEntry describes a single item stored in a Backup
|
||||
type DetailsEntry struct {
|
||||
// Entry describes a single item stored in a Backup
|
||||
type Entry struct {
|
||||
// RepoRef is the full storage path of the item in Kopia
|
||||
RepoRef string `json:"repoRef"`
|
||||
ShortRef string `json:"shortRef"`
|
||||
@ -490,7 +490,7 @@ type DetailsEntry struct {
|
||||
// ToLocationIDer takes a backup version and produces the unique location for
|
||||
// this entry if possible. Reasons it may not be possible to produce the unique
|
||||
// location include an unsupported backup version or missing information.
|
||||
func (de DetailsEntry) ToLocationIDer(backupVersion int) (LocationIDer, error) {
|
||||
func (de Entry) ToLocationIDer(backupVersion int) (LocationIDer, error) {
|
||||
if len(de.LocationRef) > 0 {
|
||||
baseLoc, err := path.Builder{}.SplitUnescapeAppend(de.LocationRef)
|
||||
if err != nil {
|
||||
@ -538,17 +538,17 @@ func (de DetailsEntry) ToLocationIDer(backupVersion int) (LocationIDer, error) {
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
// interface compliance checks
|
||||
var _ print.Printable = &DetailsEntry{}
|
||||
var _ print.Printable = &Entry{}
|
||||
|
||||
// MinimumPrintable DetailsEntries is a passthrough func, because no
|
||||
// reduction is needed for the json output.
|
||||
func (de DetailsEntry) MinimumPrintable() any {
|
||||
func (de Entry) MinimumPrintable() any {
|
||||
return de
|
||||
}
|
||||
|
||||
// Headers returns the human-readable names of properties in a DetailsEntry
|
||||
// for printing out to a terminal in a columnar display.
|
||||
func (de DetailsEntry) Headers() []string {
|
||||
func (de Entry) Headers() []string {
|
||||
hs := []string{"ID"}
|
||||
|
||||
if de.ItemInfo.Folder != nil {
|
||||
@ -571,7 +571,7 @@ func (de DetailsEntry) Headers() []string {
|
||||
}
|
||||
|
||||
// Values returns the values matching the Headers list.
|
||||
func (de DetailsEntry) Values() []string {
|
||||
func (de Entry) Values() []string {
|
||||
vs := []string{de.ShortRef}
|
||||
|
||||
if de.ItemInfo.Folder != nil {
|
||||
|
||||
@ -40,13 +40,13 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
entry DetailsEntry
|
||||
entry Entry
|
||||
expectHs []string
|
||||
expectVs []string
|
||||
}{
|
||||
{
|
||||
name: "no info",
|
||||
entry: DetailsEntry{
|
||||
entry: Entry{
|
||||
RepoRef: "reporef",
|
||||
ShortRef: "deadbeef",
|
||||
LocationRef: "locationref",
|
||||
@ -57,7 +57,7 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
||||
},
|
||||
{
|
||||
name: "exchange event info",
|
||||
entry: DetailsEntry{
|
||||
entry: Entry{
|
||||
RepoRef: "reporef",
|
||||
ShortRef: "deadbeef",
|
||||
LocationRef: "locationref",
|
||||
@ -78,7 +78,7 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
||||
},
|
||||
{
|
||||
name: "exchange contact info",
|
||||
entry: DetailsEntry{
|
||||
entry: Entry{
|
||||
RepoRef: "reporef",
|
||||
ShortRef: "deadbeef",
|
||||
LocationRef: "locationref",
|
||||
@ -95,7 +95,7 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
||||
},
|
||||
{
|
||||
name: "exchange mail info",
|
||||
entry: DetailsEntry{
|
||||
entry: Entry{
|
||||
RepoRef: "reporef",
|
||||
ShortRef: "deadbeef",
|
||||
LocationRef: "locationref",
|
||||
@ -116,7 +116,7 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
||||
},
|
||||
{
|
||||
name: "sharepoint info",
|
||||
entry: DetailsEntry{
|
||||
entry: Entry{
|
||||
RepoRef: "reporef",
|
||||
ShortRef: "deadbeef",
|
||||
LocationRef: "locationref",
|
||||
@ -148,7 +148,7 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
||||
},
|
||||
{
|
||||
name: "oneDrive info",
|
||||
entry: DetailsEntry{
|
||||
entry: Entry{
|
||||
RepoRef: "reporef",
|
||||
ShortRef: "deadbeef",
|
||||
LocationRef: "locationref",
|
||||
@ -181,7 +181,7 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
||||
}
|
||||
}
|
||||
|
||||
func exchangeEntry(t *testing.T, id string, size int, it ItemType) DetailsEntry {
|
||||
func exchangeEntry(t *testing.T, id string, size int, it ItemType) Entry {
|
||||
rr := makeItemPath(
|
||||
t,
|
||||
path.ExchangeService,
|
||||
@ -190,7 +190,7 @@ func exchangeEntry(t *testing.T, id string, size int, it ItemType) DetailsEntry
|
||||
"user-id",
|
||||
[]string{"Inbox", "folder1", id})
|
||||
|
||||
return DetailsEntry{
|
||||
return Entry{
|
||||
RepoRef: rr.String(),
|
||||
ShortRef: rr.ShortRef(),
|
||||
ParentRef: rr.ToBuilder().Dir().ShortRef(),
|
||||
@ -206,7 +206,7 @@ func exchangeEntry(t *testing.T, id string, size int, it ItemType) DetailsEntry
|
||||
}
|
||||
}
|
||||
|
||||
func oneDriveishEntry(t *testing.T, id string, size int, it ItemType) DetailsEntry {
|
||||
func oneDriveishEntry(t *testing.T, id string, size int, it ItemType) Entry {
|
||||
service := path.OneDriveService
|
||||
category := path.FilesCategory
|
||||
info := ItemInfo{
|
||||
@ -252,7 +252,7 @@ func oneDriveishEntry(t *testing.T, id string, size int, it ItemType) DetailsEnt
|
||||
|
||||
loc := path.Builder{}.Append(rr.Folders()...).PopFront().PopFront()
|
||||
|
||||
return DetailsEntry{
|
||||
return Entry{
|
||||
RepoRef: rr.String(),
|
||||
ShortRef: rr.ShortRef(),
|
||||
ParentRef: rr.ToBuilder().Dir().ShortRef(),
|
||||
@ -268,7 +268,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_NoLocationFolders() {
|
||||
t := suite.T()
|
||||
table := []struct {
|
||||
name string
|
||||
entry DetailsEntry
|
||||
entry Entry
|
||||
// shortRefEqual allows checking that OneDrive and SharePoint have their
|
||||
// ShortRef updated in the returned entry.
|
||||
//
|
||||
@ -293,7 +293,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_NoLocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "Legacy SharePoint File",
|
||||
entry: func() DetailsEntry {
|
||||
entry: func() Entry {
|
||||
res := oneDriveishEntry(t, itemID, 42, SharePointLibrary)
|
||||
res.SharePoint.ItemType = OneDriveItem
|
||||
|
||||
@ -360,7 +360,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
exchangeMail2 := exchangeEntry(t, "foo2", 43, ExchangeMail)
|
||||
exchangeContact1 := exchangeEntry(t, "foo3", 44, ExchangeContact)
|
||||
|
||||
exchangeFolders := []DetailsEntry{
|
||||
exchangeFolders := []Entry{
|
||||
{
|
||||
ItemInfo: ItemInfo{
|
||||
Folder: &FolderInfo{
|
||||
@ -382,7 +382,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
}
|
||||
|
||||
exchangeContactFolders := []DetailsEntry{
|
||||
exchangeContactFolders := []Entry{
|
||||
{
|
||||
ItemInfo: ItemInfo{
|
||||
Folder: &FolderInfo{
|
||||
@ -404,7 +404,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
}
|
||||
|
||||
oneDriveishFolders := []DetailsEntry{
|
||||
oneDriveishFolders := []Entry{
|
||||
{
|
||||
ItemInfo: ItemInfo{
|
||||
Folder: &FolderInfo{
|
||||
@ -441,20 +441,20 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
entries func() []DetailsEntry
|
||||
expectedDirs func() []DetailsEntry
|
||||
entries func() []Entry
|
||||
expectedDirs func() []Entry
|
||||
}{
|
||||
{
|
||||
name: "One Exchange Email None Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
entries: func() []Entry {
|
||||
e := exchangeMail1
|
||||
ei := *exchangeMail1.Exchange
|
||||
e.Exchange = &ei
|
||||
|
||||
return []DetailsEntry{e}
|
||||
return []Entry{e}
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range exchangeFolders {
|
||||
e := entry
|
||||
@ -472,16 +472,16 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "One Exchange Email Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
entries: func() []Entry {
|
||||
e := exchangeMail1
|
||||
ei := *exchangeMail1.Exchange
|
||||
e.Exchange = &ei
|
||||
e.Updated = true
|
||||
|
||||
return []DetailsEntry{e}
|
||||
return []Entry{e}
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range exchangeFolders {
|
||||
e := entry
|
||||
@ -500,10 +500,10 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "Two Exchange Emails None Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
entries: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range []DetailsEntry{exchangeMail1, exchangeMail2} {
|
||||
for _, entry := range []Entry{exchangeMail1, exchangeMail2} {
|
||||
e := entry
|
||||
ei := *entry.Exchange
|
||||
e.Exchange = &ei
|
||||
@ -513,8 +513,8 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
|
||||
return res
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range exchangeFolders {
|
||||
e := entry
|
||||
@ -532,10 +532,10 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "Two Exchange Emails One Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
entries: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for i, entry := range []DetailsEntry{exchangeMail1, exchangeMail2} {
|
||||
for i, entry := range []Entry{exchangeMail1, exchangeMail2} {
|
||||
e := entry
|
||||
ei := *entry.Exchange
|
||||
e.Exchange = &ei
|
||||
@ -546,8 +546,8 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
|
||||
return res
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range exchangeFolders {
|
||||
e := entry
|
||||
@ -566,10 +566,10 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "One Email And One Contact None Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
entries: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range []DetailsEntry{exchangeMail1, exchangeContact1} {
|
||||
for _, entry := range []Entry{exchangeMail1, exchangeContact1} {
|
||||
e := entry
|
||||
ei := *entry.Exchange
|
||||
e.Exchange = &ei
|
||||
@ -579,8 +579,8 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
|
||||
return res
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range exchangeFolders {
|
||||
e := entry
|
||||
@ -609,15 +609,15 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "One OneDrive Item None Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
entries: func() []Entry {
|
||||
e := oneDrive1
|
||||
ei := *oneDrive1.OneDrive
|
||||
e.OneDrive = &ei
|
||||
|
||||
return []DetailsEntry{e}
|
||||
return []Entry{e}
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range oneDriveishFolders {
|
||||
e := entry
|
||||
@ -636,15 +636,15 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "One SharePoint Item None Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
entries: func() []Entry {
|
||||
e := sharePoint1
|
||||
ei := *sharePoint1.SharePoint
|
||||
e.SharePoint = &ei
|
||||
|
||||
return []DetailsEntry{e}
|
||||
return []Entry{e}
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range oneDriveishFolders {
|
||||
e := entry
|
||||
@ -663,15 +663,15 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
},
|
||||
{
|
||||
name: "One SharePoint Legacy Item None Updated",
|
||||
entries: func() []DetailsEntry {
|
||||
entries: func() []Entry {
|
||||
e := sharePoint1
|
||||
ei := *sharePoint1.SharePoint
|
||||
e.SharePoint = &ei
|
||||
|
||||
return []DetailsEntry{e}
|
||||
return []Entry{e}
|
||||
},
|
||||
expectedDirs: func() []DetailsEntry {
|
||||
res := []DetailsEntry{}
|
||||
expectedDirs: func() []Entry {
|
||||
res := []Entry{}
|
||||
|
||||
for _, entry := range oneDriveishFolders {
|
||||
e := entry
|
||||
@ -707,7 +707,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
}
|
||||
|
||||
deets := db.Details()
|
||||
gotDirs := []DetailsEntry{}
|
||||
gotDirs := []Entry{}
|
||||
|
||||
for _, entry := range deets.Entries {
|
||||
// Other test checks items are populated properly.
|
||||
@ -730,7 +730,7 @@ func (suite *DetailsUnitSuite) TestDetailsAdd_LocationFolders() {
|
||||
|
||||
var pathItemsTable = []struct {
|
||||
name string
|
||||
ents []DetailsEntry
|
||||
ents []Entry
|
||||
expectRepoRefs []string
|
||||
expectLocationRefs []string
|
||||
}{
|
||||
@ -742,7 +742,7 @@ var pathItemsTable = []struct {
|
||||
},
|
||||
{
|
||||
name: "single entry",
|
||||
ents: []DetailsEntry{
|
||||
ents: []Entry{
|
||||
{
|
||||
RepoRef: "abcde",
|
||||
LocationRef: "locationref",
|
||||
@ -754,7 +754,7 @@ var pathItemsTable = []struct {
|
||||
},
|
||||
{
|
||||
name: "multiple entries",
|
||||
ents: []DetailsEntry{
|
||||
ents: []Entry{
|
||||
{
|
||||
RepoRef: "abcde",
|
||||
LocationRef: "locationref",
|
||||
@ -771,7 +771,7 @@ var pathItemsTable = []struct {
|
||||
},
|
||||
{
|
||||
name: "multiple entries with folder",
|
||||
ents: []DetailsEntry{
|
||||
ents: []Entry{
|
||||
{
|
||||
RepoRef: "abcde",
|
||||
LocationRef: "locationref",
|
||||
@ -797,7 +797,7 @@ var pathItemsTable = []struct {
|
||||
},
|
||||
{
|
||||
name: "multiple entries with meta file",
|
||||
ents: []DetailsEntry{
|
||||
ents: []Entry{
|
||||
{
|
||||
RepoRef: "abcde",
|
||||
LocationRef: "locationref",
|
||||
@ -824,7 +824,7 @@ var pathItemsTable = []struct {
|
||||
},
|
||||
{
|
||||
name: "multiple entries with folder and meta file",
|
||||
ents: []DetailsEntry{
|
||||
ents: []Entry{
|
||||
{
|
||||
RepoRef: "abcde",
|
||||
LocationRef: "locationref",
|
||||
@ -908,7 +908,7 @@ func (suite *DetailsUnitSuite) TestDetailsModel_FilterMetaFiles() {
|
||||
t := suite.T()
|
||||
|
||||
d := &DetailsModel{
|
||||
Entries: []DetailsEntry{
|
||||
Entries: []Entry{
|
||||
{
|
||||
RepoRef: "a.data",
|
||||
ItemInfo: ItemInfo{
|
||||
@ -1360,7 +1360,7 @@ func (suite *DetailsUnitSuite) TestLocationIDer_FromEntry() {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
entry := DetailsEntry{
|
||||
entry := Entry{
|
||||
RepoRef: fmt.Sprintf(rrString, test.service, test.category),
|
||||
ItemInfo: test.itemInfo,
|
||||
}
|
||||
|
||||
12
src/pkg/backup/details/testdata/testdata.go
vendored
12
src/pkg/backup/details/testdata/testdata.go
vendored
@ -145,7 +145,7 @@ var (
|
||||
ExchangeEmailItemPath2 = ExchangeEmailBasePath2.mustAppend(ItemName2, true)
|
||||
ExchangeEmailItemPath3 = ExchangeEmailBasePath3.mustAppend(ItemName3, true)
|
||||
|
||||
ExchangeEmailItems = []details.DetailsEntry{
|
||||
ExchangeEmailItems = []details.Entry{
|
||||
{
|
||||
RepoRef: ExchangeEmailItemPath1.RR.String(),
|
||||
ShortRef: ExchangeEmailItemPath1.RR.ShortRef(),
|
||||
@ -199,7 +199,7 @@ var (
|
||||
ExchangeContactsItemPath1 = ExchangeContactsBasePath.mustAppend(ItemName1, true)
|
||||
ExchangeContactsItemPath2 = ExchangeContactsBasePath2.mustAppend(ItemName2, true)
|
||||
|
||||
ExchangeContactsItems = []details.DetailsEntry{
|
||||
ExchangeContactsItems = []details.Entry{
|
||||
{
|
||||
RepoRef: ExchangeContactsItemPath1.RR.String(),
|
||||
ShortRef: ExchangeContactsItemPath1.RR.ShortRef(),
|
||||
@ -234,7 +234,7 @@ var (
|
||||
ExchangeEventsItemPath1 = ExchangeEventsBasePath.mustAppend(ItemName1, true)
|
||||
ExchangeEventsItemPath2 = ExchangeEventsBasePath2.mustAppend(ItemName2, true)
|
||||
|
||||
ExchangeEventsItems = []details.DetailsEntry{
|
||||
ExchangeEventsItems = []details.Entry{
|
||||
{
|
||||
RepoRef: ExchangeEventsItemPath1.RR.String(),
|
||||
ShortRef: ExchangeEventsItemPath1.RR.ShortRef(),
|
||||
@ -282,7 +282,7 @@ var (
|
||||
OneDriveParentFolder1 = OneDriveBasePath1.loc.PopFront().String()
|
||||
OneDriveParentFolder2 = OneDriveBasePath2.loc.PopFront().String()
|
||||
|
||||
OneDriveItems = []details.DetailsEntry{
|
||||
OneDriveItems = []details.Entry{
|
||||
{
|
||||
RepoRef: OneDriveItemPath1.RR.String(),
|
||||
ShortRef: OneDriveItemPath1.RR.ShortRef(),
|
||||
@ -352,7 +352,7 @@ var (
|
||||
SharePointParentLibrary1 = SharePointBasePath1.loc.PopFront().String()
|
||||
SharePointParentLibrary2 = SharePointBasePath2.loc.PopFront().String()
|
||||
|
||||
SharePointLibraryItems = []details.DetailsEntry{
|
||||
SharePointLibraryItems = []details.Entry{
|
||||
{
|
||||
RepoRef: SharePointLibraryItemPath1.RR.String(),
|
||||
ShortRef: SharePointLibraryItemPath1.RR.ShortRef(),
|
||||
@ -411,7 +411,7 @@ var (
|
||||
)
|
||||
|
||||
func GetDetailsSet() *details.Details {
|
||||
entries := []details.DetailsEntry{}
|
||||
entries := []details.Entry{}
|
||||
|
||||
for _, e := range ExchangeEmailItems {
|
||||
entries = append(entries, e)
|
||||
|
||||
@ -302,10 +302,10 @@ func doRestoreLoadTest(
|
||||
}
|
||||
|
||||
// noFolders removes all "folder" category details entries
|
||||
func noFolders(t *testing.T, des []details.DetailsEntry) []details.DetailsEntry {
|
||||
func noFolders(t *testing.T, des []details.Entry) []details.Entry {
|
||||
t.Helper()
|
||||
|
||||
sansfldr := []details.DetailsEntry{}
|
||||
sansfldr := []details.Entry{}
|
||||
|
||||
for _, ent := range des {
|
||||
if ent.Folder == nil {
|
||||
|
||||
@ -121,7 +121,7 @@ var (
|
||||
ctxBG = context.Background()
|
||||
exampleDetails = &details.Details{
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
{
|
||||
RepoRef: "tID/exchange/your-user-id/email/example/itemID",
|
||||
LocationRef: "example",
|
||||
|
||||
@ -593,7 +593,7 @@ func (ec exchangeCategory) isLeaf() bool {
|
||||
// => {exchMailFolder: mailFolder, exchMail: mailID}
|
||||
func (ec exchangeCategory) pathValues(
|
||||
repo path.Path,
|
||||
ent details.DetailsEntry,
|
||||
ent details.Entry,
|
||||
cfg Config,
|
||||
) (map[categorizer][]string, error) {
|
||||
var folderCat, itemCat categorizer
|
||||
|
||||
@ -725,7 +725,7 @@ func (suite *ExchangeSelectorSuite) TestExchangeScope_MatchesPath() {
|
||||
loc = strings.Join([]string{fld1, fld2, mail}, "/")
|
||||
short = "thisisahashofsomekind"
|
||||
es = NewExchangeRestore(Any())
|
||||
ent = details.DetailsEntry{
|
||||
ent = details.Entry{
|
||||
RepoRef: repo.String(),
|
||||
ShortRef: short,
|
||||
ItemRef: mail,
|
||||
@ -822,7 +822,7 @@ func (suite *ExchangeSelectorSuite) TestExchangeRestore_Reduce() {
|
||||
makeDeets := func(refs ...path.Path) *details.Details {
|
||||
deets := &details.Details{
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{},
|
||||
Entries: []details.Entry{},
|
||||
},
|
||||
}
|
||||
|
||||
@ -838,7 +838,7 @@ func (suite *ExchangeSelectorSuite) TestExchangeRestore_Reduce() {
|
||||
itype = details.ExchangeMail
|
||||
}
|
||||
|
||||
deets.Entries = append(deets.Entries, details.DetailsEntry{
|
||||
deets.Entries = append(deets.Entries, details.Entry{
|
||||
RepoRef: toRR(r),
|
||||
// Don't escape because we assume nice paths.
|
||||
LocationRef: r.Folder(false),
|
||||
@ -1069,7 +1069,7 @@ func (suite *ExchangeSelectorSuite) TestExchangeRestore_Reduce_locationRef() {
|
||||
makeDeets := func(refs ...string) *details.Details {
|
||||
deets := &details.Details{
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{},
|
||||
Entries: []details.Entry{},
|
||||
},
|
||||
}
|
||||
|
||||
@ -1091,7 +1091,7 @@ func (suite *ExchangeSelectorSuite) TestExchangeRestore_Reduce_locationRef() {
|
||||
location = mailLocation
|
||||
}
|
||||
|
||||
deets.Entries = append(deets.Entries, details.DetailsEntry{
|
||||
deets.Entries = append(deets.Entries, details.Entry{
|
||||
RepoRef: r,
|
||||
LocationRef: location,
|
||||
ItemInfo: details.ItemInfo{
|
||||
@ -1345,7 +1345,7 @@ func (suite *ExchangeSelectorSuite) TestPasses() {
|
||||
)
|
||||
|
||||
short := "thisisahashofsomekind"
|
||||
entry := details.DetailsEntry{
|
||||
entry := details.Entry{
|
||||
ShortRef: short,
|
||||
ItemRef: mid,
|
||||
}
|
||||
@ -1357,7 +1357,7 @@ func (suite *ExchangeSelectorSuite) TestPasses() {
|
||||
noMail = setScopesToDefault(es.Mails(Any(), None()))
|
||||
allMail = setScopesToDefault(es.Mails(Any(), Any()))
|
||||
repo = stubPath(suite.T(), "user", []string{"folder", mid}, path.EmailCategory)
|
||||
ent = details.DetailsEntry{
|
||||
ent = details.Entry{
|
||||
RepoRef: repo.String(),
|
||||
}
|
||||
)
|
||||
@ -1524,7 +1524,7 @@ func (suite *ExchangeSelectorSuite) TestExchangeCategory_PathValues() {
|
||||
for _, test := range table {
|
||||
suite.Run(string(test.cat), func() {
|
||||
t := suite.T()
|
||||
ent := details.DetailsEntry{
|
||||
ent := details.Entry{
|
||||
RepoRef: test.path.String(),
|
||||
ShortRef: "short",
|
||||
LocationRef: test.loc.Folder(true),
|
||||
|
||||
@ -59,7 +59,7 @@ func (mc mockCategorizer) isLeaf() bool {
|
||||
|
||||
func (mc mockCategorizer) pathValues(
|
||||
repo path.Path,
|
||||
ent details.DetailsEntry,
|
||||
ent details.Entry,
|
||||
cfg Config,
|
||||
) (map[categorizer][]string, error) {
|
||||
return map[categorizer][]string{
|
||||
|
||||
@ -391,7 +391,7 @@ func (c oneDriveCategory) isLeaf() bool {
|
||||
// => {odFolder: folder, odFileID: fileID}
|
||||
func (c oneDriveCategory) pathValues(
|
||||
repo path.Path,
|
||||
ent details.DetailsEntry,
|
||||
ent details.Entry,
|
||||
cfg Config,
|
||||
) (map[categorizer][]string, error) {
|
||||
if ent.OneDrive == nil {
|
||||
|
||||
@ -188,7 +188,7 @@ func (suite *OneDriveSelectorSuite) TestOneDriveRestore_Reduce() {
|
||||
|
||||
deets := &details.Details{
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
{
|
||||
RepoRef: file,
|
||||
ItemRef: "file",
|
||||
@ -361,7 +361,7 @@ func (suite *OneDriveSelectorSuite) TestOneDriveCategory_PathValues() {
|
||||
test.pathElems...)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ent := details.DetailsEntry{
|
||||
ent := details.Entry{
|
||||
RepoRef: filePath.String(),
|
||||
ShortRef: shortRef,
|
||||
ItemRef: fileID,
|
||||
|
||||
@ -89,7 +89,7 @@ type (
|
||||
// folderCat: folder,
|
||||
// itemCat: itemID,
|
||||
// }
|
||||
pathValues(path.Path, details.DetailsEntry, Config) (map[categorizer][]string, error)
|
||||
pathValues(path.Path, details.Entry, Config) (map[categorizer][]string, error)
|
||||
|
||||
// pathKeys produces a list of categorizers that can be used as keys in the pathValues
|
||||
// map. The combination of the two funcs generically interprets the context of the
|
||||
@ -360,7 +360,7 @@ func reduce[T scopeT, C categoryT](
|
||||
filts := scopesByCategory[T](s.Filters, dataCategories, true)
|
||||
incls := scopesByCategory[T](s.Includes, dataCategories, false)
|
||||
|
||||
ents := []details.DetailsEntry{}
|
||||
ents := []details.Entry{}
|
||||
|
||||
// for each entry, compare that entry against the scopes of the same data type
|
||||
for _, ent := range deets.Items() {
|
||||
@ -441,7 +441,7 @@ func scopesByCategory[T scopeT, C categoryT](
|
||||
func passes[T scopeT, C categoryT](
|
||||
cat C,
|
||||
pathValues map[categorizer][]string,
|
||||
entry details.DetailsEntry,
|
||||
entry details.Entry,
|
||||
excs, filts, incs []T,
|
||||
) bool {
|
||||
// a passing match requires either a filter or an inclusion
|
||||
@ -490,7 +490,7 @@ func matchesEntry[T scopeT, C categoryT](
|
||||
sc T,
|
||||
cat C,
|
||||
pathValues map[categorizer][]string,
|
||||
entry details.DetailsEntry,
|
||||
entry details.Entry,
|
||||
) bool {
|
||||
// InfoCategory requires matching against service-specific info values
|
||||
if len(getInfoCategory(sc)) > 0 {
|
||||
|
||||
@ -257,7 +257,7 @@ func (suite *SelectorScopesSuite) TestReduce() {
|
||||
deets := func() details.Details {
|
||||
return details.Details{
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
{
|
||||
RepoRef: stubRepoRef(
|
||||
pathServiceStub,
|
||||
@ -302,7 +302,7 @@ func (suite *SelectorScopesSuite) TestReduce_locationRef() {
|
||||
deets := func() details.Details {
|
||||
return details.Details{
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
{
|
||||
RepoRef: stubRepoRef(
|
||||
pathServiceStub,
|
||||
@ -361,7 +361,7 @@ func (suite *SelectorScopesSuite) TestPasses() {
|
||||
var (
|
||||
cat = rootCatStub
|
||||
pth = stubPath(suite.T(), "uid", []string{"fld"}, path.EventsCategory)
|
||||
entry = details.DetailsEntry{
|
||||
entry = details.Entry{
|
||||
RepoRef: pth.String(),
|
||||
}
|
||||
)
|
||||
|
||||
@ -31,7 +31,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
table := []struct {
|
||||
name string
|
||||
selFunc func() selectors.Reducer
|
||||
expected []details.DetailsEntry
|
||||
expected []details.Entry
|
||||
}{
|
||||
{
|
||||
name: "ExchangeAllMail",
|
||||
@ -63,7 +63,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeMailSubjectExcludeItem",
|
||||
@ -77,7 +77,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeMailSender",
|
||||
@ -87,7 +87,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{
|
||||
expected: []details.Entry{
|
||||
testdata.ExchangeEmailItems[0],
|
||||
testdata.ExchangeEmailItems[1],
|
||||
},
|
||||
@ -102,7 +102,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeMailID",
|
||||
@ -115,7 +115,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeMailShortRef",
|
||||
@ -128,7 +128,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeAllEventsAndMailWithSubject",
|
||||
@ -142,7 +142,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeEventsAndMailWithSubject",
|
||||
@ -153,7 +153,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{},
|
||||
expected: []details.Entry{},
|
||||
},
|
||||
{
|
||||
name: "ExchangeAll",
|
||||
@ -166,7 +166,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
expected: append(
|
||||
append(
|
||||
append(
|
||||
[]details.DetailsEntry{},
|
||||
[]details.Entry{},
|
||||
testdata.ExchangeEmailItems...),
|
||||
testdata.ExchangeContactsItems...),
|
||||
testdata.ExchangeEventsItems...,
|
||||
@ -182,7 +182,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
// TODO (keepers): all folders are treated as prefix-matches at this time.
|
||||
// so this test actually does nothing different. In the future, we'll
|
||||
@ -198,7 +198,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEmailItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEmailItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeMailByFolderRoot",
|
||||
@ -222,7 +222,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeContactsItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeContactsItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeContactByFolderRoot",
|
||||
@ -247,7 +247,7 @@ func (suite *SelectorReduceSuite) TestReduce() {
|
||||
|
||||
return sel
|
||||
},
|
||||
expected: []details.DetailsEntry{testdata.ExchangeEventsItems[0]},
|
||||
expected: []details.Entry{testdata.ExchangeEventsItems[0]},
|
||||
},
|
||||
{
|
||||
name: "ExchangeEventsByFolderRoot",
|
||||
|
||||
@ -516,7 +516,7 @@ func (c sharePointCategory) isLeaf() bool {
|
||||
// => {spFolder: folder, spItemID: itemID}
|
||||
func (c sharePointCategory) pathValues(
|
||||
repo path.Path,
|
||||
ent details.DetailsEntry,
|
||||
ent details.Entry,
|
||||
cfg Config,
|
||||
) (map[categorizer][]string, error) {
|
||||
var (
|
||||
|
||||
@ -253,7 +253,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
|
||||
deets := &details.Details{
|
||||
DetailsModel: details.DetailsModel{
|
||||
Entries: []details.DetailsEntry{
|
||||
Entries: []details.Entry{
|
||||
{
|
||||
RepoRef: item,
|
||||
ItemRef: "item",
|
||||
@ -478,7 +478,7 @@ func (suite *SharePointSelectorSuite) TestSharePointCategory_PathValues() {
|
||||
test.pathElems...)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
ent := details.DetailsEntry{
|
||||
ent := details.Entry{
|
||||
RepoRef: itemPath.String(),
|
||||
ShortRef: shortRef,
|
||||
ItemRef: itemPath.Item(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user