Add shortref and rename item_id (#4868)

<!-- PR description-->

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #<issue>

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abin Simon 2023-12-18 14:12:40 +05:30 committed by GitHub
parent 83d9492b4f
commit 891814f15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -44,7 +44,7 @@ func FromJSON(ctx context.Context, body []byte) (string, error) {
return "", clues.Wrap(err, "converting to messageble")
}
ctx = clues.Add(ctx, "id", ptr.Val(data.GetId()))
ctx = clues.Add(ctx, "item_id", ptr.Val(data.GetId()))
email := mail.NewMSG()
email.AllowDuplicateAddress = true // More "correct" conversion

View File

@ -44,7 +44,9 @@ func streamItems(
errs := fault.New(false)
for _, rc := range drc {
for item := range rc.Items(ctx, errs) {
ictx := clues.Add(ctx, "path_short_ref", rc.FullPath().ShortRef())
for item := range rc.Items(ictx, errs) {
id := item.ID()
name := id + ".eml"
@ -64,7 +66,7 @@ func streamItems(
continue
}
email, err := eml.FromJSON(ctx, content)
email, err := eml.FromJSON(ictx, content)
if err != nil {
ch <- export.Item{
ID: id,

View File

@ -33,6 +33,10 @@ func TestExportUnitSuite(t *testing.T) {
func (suite *ExportUnitSuite) TestGetItems() {
emailBodyBytes := []byte(testdata.EmailWithAttachments)
pb := path.Builder{}.Append("Inbox")
p, err := pb.ToDataLayerPath("t", "r", path.ExchangeService, path.EmailCategory, false)
assert.NoError(suite.T(), err, "build path")
table := []struct {
name string
version int
@ -44,6 +48,7 @@ func (suite *ExportUnitSuite) TestGetItems() {
version: 1,
backingCollection: data.NoFetchRestoreCollection{
Collection: dataMock.Collection{
Path: p,
ItemData: []data.Item{
&dataMock.Item{
ItemID: "id1",
@ -65,6 +70,7 @@ func (suite *ExportUnitSuite) TestGetItems() {
version: 1,
backingCollection: data.NoFetchRestoreCollection{
Collection: dataMock.Collection{
Path: p,
ItemData: []data.Item{
&dataMock.Item{
ItemID: "id1",
@ -95,6 +101,7 @@ func (suite *ExportUnitSuite) TestGetItems() {
version: version.Groups9Update,
backingCollection: data.FetchRestoreCollection{
Collection: dataMock.Collection{
Path: p,
ItemData: []data.Item{
&dataMock.Item{
ItemID: "id0",