Compare commits
15 Commits
main
...
serialize-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4daa86fcc7 | ||
|
|
c0e1b3db7e | ||
|
|
a1e1ebb5c3 | ||
|
|
91f2556e4c | ||
|
|
5ac97ec856 | ||
|
|
d2b7ac0d0c | ||
|
|
9ab2d96451 | ||
|
|
886015126a | ||
|
|
dd42105b3e | ||
|
|
8a919ead95 | ||
|
|
5f3d9266a3 | ||
|
|
6dedf1807c | ||
|
|
105314d379 | ||
|
|
d331ad8ecf | ||
|
|
9a872fd388 |
@ -20,6 +20,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/connector"
|
||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||
"github.com/alcionai/corso/src/internal/connector/support"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/credentials"
|
||||
@ -117,7 +118,7 @@ func runDisplayM365JSON(
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, support.ConnectorStackErrorTrace(err))
|
||||
}
|
||||
|
||||
str := string(bs)
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/connector/support"
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
@ -45,10 +46,15 @@ func (s Service) Client() *msgraphsdk.GraphServiceClient {
|
||||
return s.client
|
||||
}
|
||||
|
||||
// Seraialize writes an M365 parsable object into a byte array using the built-in
|
||||
// application/json writer within the adapter.
|
||||
func (s Service) Serialize(object absser.Parsable) ([]byte, error) {
|
||||
writer, err := s.adapter.GetSerializationWriterFactory().GetSerializationWriter("application/json")
|
||||
defer func() {
|
||||
writerErr := writer.Close()
|
||||
if writerErr != nil {
|
||||
err = support.WrapAndAppend("failure during writer closer", writerErr, err)
|
||||
}
|
||||
}()
|
||||
|
||||
if err != nil || writer == nil {
|
||||
return nil, errors.Wrap(err, "creating json serialization writer")
|
||||
}
|
||||
@ -68,6 +74,10 @@ type Servicer interface {
|
||||
// Adapter() returns GraphRequest adapter used to process large requests, create batches
|
||||
// and page iterators
|
||||
Adapter() *msgraphsdk.GraphRequestAdapter
|
||||
|
||||
// Seraialize writes an M365 parsable object into a byte array using the built-in
|
||||
// application/json writer within the adapter.
|
||||
Serialize(object absser.Parsable) ([]byte, error)
|
||||
}
|
||||
|
||||
// Idable represents objects that implement msgraph-sdk-go/models.entityable
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -37,6 +38,10 @@ func (suite *CollectionUnitTestSuite) Adapter() *msgraphsdk.GraphRequestAdapter
|
||||
return nil
|
||||
}
|
||||
|
||||
func (suite *CollectionUnitTestSuite) Serialize(object absser.Parsable) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func TestCollectionUnitTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(CollectionUnitTestSuite))
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -34,6 +35,10 @@ func (suite *ItemIntegrationSuite) Adapter() *msgraphsdk.GraphRequestAdapter {
|
||||
return suite.adapter
|
||||
}
|
||||
|
||||
func (suite *ItemIntegrationSuite) Serialize(object absser.Parsable) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func TestItemIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
t,
|
||||
|
||||
@ -3,6 +3,7 @@ package onedrive
|
||||
import (
|
||||
"testing"
|
||||
|
||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -22,6 +23,10 @@ func (ms *MockGraphService) Adapter() *msgraphsdk.GraphRequestAdapter {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *MockGraphService) Serialize(object absser.Parsable) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// TODO(ashmrtn): Merge with similar structs in graph and exchange packages.
|
||||
type oneDriveService struct {
|
||||
client msgraphsdk.GraphServiceClient
|
||||
@ -38,6 +43,10 @@ func (ods *oneDriveService) Adapter() *msgraphsdk.GraphRequestAdapter {
|
||||
return &ods.adapter
|
||||
}
|
||||
|
||||
func (ods *oneDriveService) Serialize(object absser.Parsable) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewOneDriveService(credentials account.M365Config) (*oneDriveService, error) {
|
||||
adapter, err := graph.CreateAdapter(
|
||||
credentials.AzureTenantID,
|
||||
|
||||
@ -3,6 +3,8 @@ package sharepoint
|
||||
import (
|
||||
"testing"
|
||||
|
||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@ -39,6 +41,21 @@ func (fm testFolderMatcher) Matches(path string) bool {
|
||||
|
||||
type SharePointLibrariesSuite struct {
|
||||
suite.Suite
|
||||
mockService mockServicer
|
||||
}
|
||||
|
||||
type mockServicer struct{}
|
||||
|
||||
func (mock mockServicer) Client() *msgraphsdk.GraphServiceClient {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mock mockServicer) Adapter() *msgraphsdk.GraphRequestAdapter {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mock mockServicer) Serialize(object absser.Parsable) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func TestSharePointLibrariesSuite(t *testing.T) {
|
||||
@ -93,7 +110,7 @@ func (suite *SharePointLibrariesSuite) TestUpdateCollections() {
|
||||
site,
|
||||
onedrive.SharePointSource,
|
||||
testFolderMatcher{test.scope},
|
||||
&MockGraphService{},
|
||||
suite.mockService,
|
||||
nil,
|
||||
control.Options{})
|
||||
err := c.UpdateCollections(ctx, "driveID", test.items, paths)
|
||||
|
||||
@ -3,7 +3,6 @@ package sharepoint
|
||||
import (
|
||||
"testing"
|
||||
|
||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -12,23 +11,6 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// SharePoint Test Services
|
||||
// ---------------------------------------------------------------------------
|
||||
type MockGraphService struct{}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Interface Functions: @See graph.Service
|
||||
//------------------------------------------------------------
|
||||
|
||||
func (ms *MockGraphService) Client() *msgraphsdk.GraphServiceClient {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *MockGraphService) Adapter() *msgraphsdk.GraphRequestAdapter {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helper Functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user