Add size to all objects (#1491)
## Description Add size to all objects. Not adding them to the output of details view. ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * https://github.com/alcionai/corso/issues/1366 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
44735d6044
commit
110684d5f7
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// ContactInfo translate models.Contactable metadata into searchable content
|
||||
func ContactInfo(contact models.Contactable) *details.ExchangeInfo {
|
||||
func ContactInfo(contact models.Contactable, size int64) *details.ExchangeInfo {
|
||||
name := ""
|
||||
created := time.Time{}
|
||||
modified := time.Time{}
|
||||
@ -31,5 +31,6 @@ func ContactInfo(contact models.Contactable) *details.ExchangeInfo {
|
||||
ContactName: name,
|
||||
Created: created,
|
||||
Modified: modified,
|
||||
Size: size,
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ func (suite *ContactSuite) TestContactInfo() {
|
||||
ItemType: details.ExchangeContact,
|
||||
Created: initial,
|
||||
Modified: initial,
|
||||
Size: 10,
|
||||
}
|
||||
return contact, i
|
||||
},
|
||||
@ -53,6 +54,7 @@ func (suite *ContactSuite) TestContactInfo() {
|
||||
ContactName: aPerson,
|
||||
Created: initial,
|
||||
Modified: initial,
|
||||
Size: 10,
|
||||
}
|
||||
return contact, i
|
||||
},
|
||||
@ -61,7 +63,7 @@ func (suite *ContactSuite) TestContactInfo() {
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
contact, expected := test.contactAndRP()
|
||||
assert.Equal(t, expected, ContactInfo(contact))
|
||||
assert.Equal(t, expected, ContactInfo(contact, 10))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// EventInfo searchable metadata for stored event objects.
|
||||
func EventInfo(evt models.Eventable) *details.ExchangeInfo {
|
||||
func EventInfo(evt models.Eventable, size int64) *details.ExchangeInfo {
|
||||
var (
|
||||
organizer, subject string
|
||||
recurs bool
|
||||
@ -77,5 +77,6 @@ func EventInfo(evt models.Eventable) *details.ExchangeInfo {
|
||||
EventRecurs: recurs,
|
||||
Created: created,
|
||||
Modified: modified,
|
||||
Size: size,
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,6 +134,7 @@ func (suite *EventSuite) TestEventInfo() {
|
||||
Organizer: organizer,
|
||||
EventStart: eventTime,
|
||||
EventEnd: eventEndTime,
|
||||
Size: 10,
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -141,7 +142,7 @@ func (suite *EventSuite) TestEventInfo() {
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
event, expected := test.evtAndRP()
|
||||
result := EventInfo(event)
|
||||
result := EventInfo(event, 10)
|
||||
|
||||
assert.Equal(t, expected.Subject, result.Subject, "subject")
|
||||
assert.Equal(t, expected.Sender, result.Sender, "sender")
|
||||
|
||||
@ -256,7 +256,7 @@ func eventToDataCollection(
|
||||
}
|
||||
|
||||
if len(byteArray) > 0 {
|
||||
dataChannel <- &Stream{id: *event.GetId(), message: byteArray, info: EventInfo(event)}
|
||||
dataChannel <- &Stream{id: *event.GetId(), message: byteArray, info: EventInfo(event, int64(len(byteArray)))}
|
||||
}
|
||||
|
||||
return len(byteArray), nil
|
||||
@ -289,7 +289,7 @@ func contactToDataCollection(
|
||||
}
|
||||
|
||||
if len(byteArray) > 0 {
|
||||
dataChannel <- &Stream{id: *contact.GetId(), message: byteArray, info: ContactInfo(contact)}
|
||||
dataChannel <- &Stream{id: *contact.GetId(), message: byteArray, info: ContactInfo(contact, int64(len(byteArray)))}
|
||||
}
|
||||
|
||||
return len(byteArray), nil
|
||||
@ -356,7 +356,7 @@ func messageToDataCollection(
|
||||
return 0, support.SetNonRecoverableError(err)
|
||||
}
|
||||
|
||||
dataChannel <- &Stream{id: *aMessage.GetId(), message: byteArray, info: MessageInfo(aMessage)}
|
||||
dataChannel <- &Stream{id: *aMessage.GetId(), message: byteArray, info: MessageInfo(aMessage, int64(len(byteArray)))}
|
||||
|
||||
return len(byteArray), nil
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
)
|
||||
|
||||
func MessageInfo(msg models.Messageable) *details.ExchangeInfo {
|
||||
func MessageInfo(msg models.Messageable, size int64) *details.ExchangeInfo {
|
||||
sender := ""
|
||||
subject := ""
|
||||
received := time.Time{}
|
||||
@ -44,5 +44,6 @@ func MessageInfo(msg models.Messageable) *details.ExchangeInfo {
|
||||
Received: received,
|
||||
Created: created,
|
||||
Modified: modified,
|
||||
Size: size,
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ func (suite *MessageSuite) TestMessageInfo() {
|
||||
ItemType: details.ExchangeMail,
|
||||
Created: initial,
|
||||
Modified: initial,
|
||||
Size: 10,
|
||||
}
|
||||
return msg, i
|
||||
},
|
||||
@ -57,6 +58,7 @@ func (suite *MessageSuite) TestMessageInfo() {
|
||||
Sender: sender,
|
||||
Created: initial,
|
||||
Modified: initial,
|
||||
Size: 10,
|
||||
}
|
||||
return msg, i
|
||||
},
|
||||
@ -74,6 +76,7 @@ func (suite *MessageSuite) TestMessageInfo() {
|
||||
Subject: subject,
|
||||
Created: initial,
|
||||
Modified: initial,
|
||||
Size: 10,
|
||||
}
|
||||
return msg, i
|
||||
},
|
||||
@ -91,6 +94,7 @@ func (suite *MessageSuite) TestMessageInfo() {
|
||||
Received: now,
|
||||
Created: initial,
|
||||
Modified: initial,
|
||||
Size: 10,
|
||||
}
|
||||
return msg, i
|
||||
},
|
||||
@ -118,6 +122,7 @@ func (suite *MessageSuite) TestMessageInfo() {
|
||||
Received: now,
|
||||
Created: initial,
|
||||
Modified: initial,
|
||||
Size: 10,
|
||||
}
|
||||
return msg, i
|
||||
},
|
||||
@ -126,7 +131,7 @@ func (suite *MessageSuite) TestMessageInfo() {
|
||||
for _, tt := range tests {
|
||||
suite.T().Run(tt.name, func(t *testing.T) {
|
||||
msg, expected := tt.msgAndRP()
|
||||
suite.Equal(expected, MessageInfo(msg))
|
||||
suite.Equal(expected, MessageInfo(msg, 10))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ func RestoreExchangeContact(
|
||||
return nil, errors.New("msgraph contact post fail: REST response not received")
|
||||
}
|
||||
|
||||
return ContactInfo(contact), nil
|
||||
return ContactInfo(contact, int64(len(bits))), nil
|
||||
}
|
||||
|
||||
// RestoreExchangeEvent restores a contact to the @bits byte
|
||||
@ -153,7 +153,7 @@ func RestoreExchangeEvent(
|
||||
}
|
||||
}
|
||||
|
||||
return EventInfo(event), errs
|
||||
return EventInfo(event, int64(len(bits))), errs
|
||||
}
|
||||
|
||||
// RestoreMailMessage utility function to place an exchange.Mail
|
||||
@ -215,7 +215,7 @@ func RestoreMailMessage(
|
||||
}
|
||||
}
|
||||
|
||||
return MessageInfo(clone), nil
|
||||
return MessageInfo(clone, int64(len(bits))), nil
|
||||
}
|
||||
|
||||
// attachmentBytes is a helper to retrieve the attachment content from a models.Attachmentable
|
||||
|
||||
@ -71,7 +71,7 @@ func (suite *SharePointCollectionSuite) TestSharePointListCollection() {
|
||||
col.data <- &Item{
|
||||
id: testName,
|
||||
data: io.NopCloser(bytes.NewReader(byteArray)),
|
||||
info: sharePointListInfo(listing),
|
||||
info: sharePointListInfo(listing, int64(len(byteArray))),
|
||||
}
|
||||
col.finishPopulation(ctx, 0, 0, nil)
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ import (
|
||||
|
||||
// sharePointListInfo translates models.Listable metadata into searchable content
|
||||
// List Details: https://learn.microsoft.com/en-us/graph/api/resources/list?view=graph-rest-1.0
|
||||
func sharePointListInfo(lst models.Listable) *details.SharePointInfo {
|
||||
func sharePointListInfo(lst models.Listable, size int64) *details.SharePointInfo {
|
||||
var (
|
||||
name, webURL string
|
||||
created, modified time.Time
|
||||
@ -38,5 +38,6 @@ func sharePointListInfo(lst models.Listable) *details.SharePointInfo {
|
||||
Created: created,
|
||||
Modified: modified,
|
||||
WebURL: webURL,
|
||||
Size: size,
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo() {
|
||||
i := &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemName: aTitle,
|
||||
Size: 10,
|
||||
}
|
||||
return listing, i
|
||||
},
|
||||
@ -46,7 +47,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo() {
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
list, expected := test.listAndRP()
|
||||
info := sharePointListInfo(list)
|
||||
info := sharePointListInfo(list, 10)
|
||||
assert.Equal(t, expected.ItemType, info.ItemType)
|
||||
assert.Equal(t, expected.ItemName, info.ItemName)
|
||||
assert.Equal(t, expected.WebURL, info.WebURL)
|
||||
|
||||
@ -304,6 +304,7 @@ type ExchangeInfo struct {
|
||||
EventRecurs bool `json:"eventRecurs,omitempty"`
|
||||
Created time.Time `json:"created,omitempty"`
|
||||
Modified time.Time `json:"modified,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// Headers returns the human-readable names of properties in an ExchangeInfo
|
||||
@ -356,6 +357,7 @@ type SharePointInfo struct {
|
||||
Created time.Time `json:"created,omitempty"`
|
||||
Modified time.Time `josn:"modified,omitempty"`
|
||||
WebURL string `json:"webUrl,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// Headers returns the human-readable names of properties in a SharePointInfo
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user