Contact / Mail folder interfaces (2) (#659)

Added 2 interfaces for future abstractions.
This commit is contained in:
Danny 2022-08-26 16:15:55 -04:00 committed by GitHub
parent 09cc2769d9
commit 2ceafd8d62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package exchange
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/alcionai/corso/internal/connector/mockconnector"
"github.com/alcionai/corso/internal/connector/support"
)
type ExchangeIteratorSuite struct {
suite.Suite
}
func TestExchangeIteratorSuite(t *testing.T) {
suite.Run(t, new(ExchangeIteratorSuite))
}
func (suite *ExchangeIteratorSuite) TestDisplayable() {
t := suite.T()
bytes := mockconnector.GetMockContactBytes("Displayable")
contact, err := support.CreateContactFromBytes(bytes)
require.NoError(t, err)
aDisplayable, ok := contact.(displayable)
assert.True(t, ok)
assert.NotNil(t, aDisplayable.GetId())
assert.NotNil(t, aDisplayable.GetDisplayName())
}
func (suite *ExchangeIteratorSuite) TestDescendable() {
t := suite.T()
bytes := mockconnector.GetMockMessageBytes("Descendable")
message, err := support.CreateMessageFromBytes(bytes)
require.NoError(t, err)
aDescendable, ok := message.(descendable)
assert.True(t, ok)
assert.NotNil(t, aDescendable.GetId())
assert.NotNil(t, aDescendable.GetParentFolderId())
}

View File

@ -18,6 +18,20 @@ const (
eventsCategory = "events"
)
// descendable represents objects that implement msgraph-sdk-go/models.entityable
// and have the concept of a "parent folder".
type descendable interface {
GetId() *string
GetParentFolderId() *string
}
// displayable represents objects that implement msgraph-sdk-fo/models.entityable
// and have the concept of a display name.
type displayable interface {
GetId() *string
GetDisplayName() *string
}
// GraphIterateFuncs are iterate functions to be used with the M365 iterators (e.g. msgraphgocore.NewPageIterator)
// @returns a callback func that works with msgraphgocore.PageIterator.Iterate function
type GraphIterateFunc func(