ContactInfo added to exchange package (#574)
ContactInfo created for models.Contactable. ContactInfo test suite created.
This commit is contained in:
parent
41f22ad9a4
commit
ad2c17876f
20
src/internal/connector/exchange/contact.go
Normal file
20
src/internal/connector/exchange/contact.go
Normal file
@ -0,0 +1,20 @@
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
|
||||
"github.com/alcionai/corso/pkg/backup/details"
|
||||
)
|
||||
|
||||
// ContactInfo translate models.Contactable metadata into searchable content
|
||||
func ContactInfo(contact models.Contactable) *details.ExchangeInfo {
|
||||
name := ""
|
||||
|
||||
if contact.GetDisplayName() != nil {
|
||||
name = *contact.GetDisplayName()
|
||||
}
|
||||
|
||||
return &details.ExchangeInfo{
|
||||
ContactName: name,
|
||||
}
|
||||
}
|
||||
46
src/internal/connector/exchange/contact_test.go
Normal file
46
src/internal/connector/exchange/contact_test.go
Normal file
@ -0,0 +1,46 @@
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/pkg/backup/details"
|
||||
)
|
||||
|
||||
type ContactSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
func TestContactSuite(t *testing.T) {
|
||||
suite.Run(t, &ContactSuite{})
|
||||
}
|
||||
|
||||
func (suite *ContactSuite) TestContactInfo() {
|
||||
tests := []struct {
|
||||
name string
|
||||
contactAndRP func() (models.Contactable, *details.ExchangeInfo)
|
||||
}{
|
||||
{
|
||||
name: "Empty Contact",
|
||||
contactAndRP: func() (models.Contactable, *details.ExchangeInfo) {
|
||||
return models.NewContact(), &details.ExchangeInfo{}
|
||||
},
|
||||
}, {
|
||||
name: "Only Name",
|
||||
contactAndRP: func() (models.Contactable, *details.ExchangeInfo) {
|
||||
aPerson := "Whole Person"
|
||||
contact := models.NewContact()
|
||||
contact.SetDisplayName(&aPerson)
|
||||
return contact, &details.ExchangeInfo{ContactName: aPerson}
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
contact, expected := test.contactAndRP()
|
||||
suite.Equal(expected, ContactInfo(contact))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -81,9 +81,10 @@ type ItemInfo struct {
|
||||
|
||||
// ExchangeInfo describes an exchange item
|
||||
type ExchangeInfo struct {
|
||||
Sender string `json:"sender"`
|
||||
Subject string `json:"subject"`
|
||||
Received time.Time `json:"received"`
|
||||
Sender string `json:"sender,omitempty"`
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Received time.Time `json:"received,omitempty"`
|
||||
ContactName string `json:"contactName,omitempty"`
|
||||
}
|
||||
|
||||
// Headers returns the human-readable names of properties in an ExchangeInfo
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user