Regression test added for serialization and (de)serialization process… (#461)

* Regression test added for serialization and (de)serialization process for graphConnector.
This commit is contained in:
Danny 2022-08-03 17:53:19 -04:00 committed by GitHub
parent 04b4f3935e
commit d656bc181c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,8 @@ package connector
import (
"bytes"
"context"
"fmt"
"strings"
"testing"
"time"
@ -86,6 +88,44 @@ func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_ExchangeDataColl
suite.Greater(len(exchangeData.FullPath()), 2)
}
func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_MailRegressionTest() {
t := suite.T()
user, err := tester.M365UserID()
require.NoError(t, err)
sel := selectors.NewExchangeBackup()
sel.Include(sel.Users([]string{user}))
eb, err := sel.ToExchangeBackup()
require.NoError(t, err)
var mailScope selectors.ExchangeScope
all := eb.Scopes()
for _, scope := range all {
fmt.Printf("%v\n", scope)
if scope.IncludesCategory(selectors.ExchangeMail) {
mailScope = scope
}
}
collection, err := suite.connector.createCollections(context.Background(), mailScope)
require.NoError(t, err)
for _, edc := range collection {
testName := strings.Join(edc.FullPath(), " ")
suite.T().Run(testName, func(t *testing.T) {
streamChannel := edc.Items()
// Verify that each message can be restored
for stream := range streamChannel {
buf := &bytes.Buffer{}
read, err := buf.ReadFrom(stream.ToReader())
suite.NoError(err)
suite.NotZero(read)
message, err := support.CreateMessageFromBytes(buf.Bytes())
suite.NotNil(message)
suite.NoError(err)
}
})
}
}
//TestGraphConnector_restoreMessages uses mock data to ensure GraphConnector
// is able to restore a messageable item to a Mailbox.
func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_restoreMessages() {