diff --git a/src/internal/connector/sharepoint/data_collections_test.go b/src/internal/connector/sharepoint/data_collections_test.go index aed554867..02f88c771 100644 --- a/src/internal/connector/sharepoint/data_collections_test.go +++ b/src/internal/connector/sharepoint/data_collections_test.go @@ -1,12 +1,10 @@ -package sharepoint_test +package sharepoint import ( "testing" - msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" "github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/alcionai/corso/src/internal/connector/onedrive" @@ -15,7 +13,7 @@ import ( ) // --------------------------------------------------------------------------- -// consts, mocks +// consts // --------------------------------------------------------------------------- const ( @@ -34,20 +32,6 @@ func (fm testFolderMatcher) Matches(path string) bool { return fm.scope.Matches(selectors.SharePointLibrary, path) } -type MockGraphService struct{} - -func (ms *MockGraphService) Client() *msgraphsdk.GraphServiceClient { - return nil -} - -func (ms *MockGraphService) Adapter() *msgraphsdk.GraphRequestAdapter { - return nil -} - -func (ms *MockGraphService) ErrPolicy() bool { - return false -} - // --------------------------------------------------------------------------- // tests // --------------------------------------------------------------------------- @@ -137,20 +121,3 @@ func driveItem(name string, path string, isFile bool) models.DriveItemable { return item } - -// --------------------------------------------------------------------------- -// Helpers -// --------------------------------------------------------------------------- - -func expectedPathAsSlice(t *testing.T, tenant, user string, rest ...string) []string { - res := make([]string, 0, len(rest)) - - for _, r := range rest { - p, err := onedrive.GetCanonicalPath(r, tenant, user, onedrive.SharePointSource) - require.NoError(t, err) - - res = append(res, p.String()) - } - - return res -} diff --git a/src/internal/connector/sharepoint/helper_test.go b/src/internal/connector/sharepoint/helper_test.go index 360bdf457..89f387957 100644 --- a/src/internal/connector/sharepoint/helper_test.go +++ b/src/internal/connector/sharepoint/helper_test.go @@ -1,13 +1,22 @@ package sharepoint import ( + "testing" + msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" "github.com/pkg/errors" + "github.com/stretchr/testify/require" "github.com/alcionai/corso/src/internal/connector/graph" + "github.com/alcionai/corso/src/internal/connector/onedrive" "github.com/alcionai/corso/src/pkg/account" ) +// --------------------------------------------------------------------------- +// SharePoint Test Services +// --------------------------------------------------------------------------- +type MockGraphService struct{} + type testService struct { client msgraphsdk.GraphServiceClient adapter msgraphsdk.GraphRequestAdapter @@ -15,9 +24,21 @@ type testService struct { } //------------------------------------------------------------ -// Functions to comply with graph.Service Interface +// Interface Functions: @See graph.Service //------------------------------------------------------------ +func (ms *MockGraphService) Client() *msgraphsdk.GraphServiceClient { + return nil +} + +func (ms *MockGraphService) Adapter() *msgraphsdk.GraphRequestAdapter { + return nil +} + +func (ms *MockGraphService) ErrPolicy() bool { + return false +} + func (ts *testService) Client() *msgraphsdk.GraphServiceClient { return &ts.client } @@ -30,6 +51,10 @@ func (ts *testService) ErrPolicy() bool { return false } +// --------------------------------------------------------------------------- +// Helper Functions +// --------------------------------------------------------------------------- + func createTestService(credentials account.M365Config) (*testService, error) { { adapter, err := graph.CreateAdapter( @@ -50,3 +75,16 @@ func createTestService(credentials account.M365Config) (*testService, error) { return &service, nil } } + +func expectedPathAsSlice(t *testing.T, tenant, user string, rest ...string) []string { + res := make([]string, 0, len(rest)) + + for _, r := range rest { + p, err := onedrive.GetCanonicalPath(r, tenant, user, onedrive.SharePointSource) + require.NoError(t, err) + + res = append(res, p.String()) + } + + return res +}