Updates /connector/sharepoint/data_collections.go and data_collections_test.go

Lint ignore removed. collectPages() method updated --> Scope not necessary
Test Suite adds test for functionality.
This commit is contained in:
Danny Adams 2023-01-27 15:40:25 -05:00
parent 5ca341eb56
commit 8b831d34f0
2 changed files with 36 additions and 3 deletions

View File

@ -163,14 +163,11 @@ func collectLibraries(
// collectPages constructs a sharepoint Collections struct and Get()s the associated // collectPages constructs a sharepoint Collections struct and Get()s the associated
// M365 IDs for the associated Pages // M365 IDs for the associated Pages
//
//nolint:unused
func collectPages( func collectPages(
ctx context.Context, ctx context.Context,
creds account.M365Config, creds account.M365Config,
serv graph.Servicer, serv graph.Servicer,
tenantID, siteID string, tenantID, siteID string,
scope selectors.SharePointScope,
updater statusUpdater, updater statusUpdater,
ctrlOpts control.Options, ctrlOpts control.Options,
) ([]data.Collection, error) { ) ([]data.Collection, error) {

View File

@ -5,10 +5,12 @@ import (
"github.com/microsoftgraph/msgraph-sdk-go/models" "github.com/microsoftgraph/msgraph-sdk-go/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/alcionai/corso/src/internal/connector/graph" "github.com/alcionai/corso/src/internal/connector/graph"
"github.com/alcionai/corso/src/internal/connector/onedrive" "github.com/alcionai/corso/src/internal/connector/onedrive"
"github.com/alcionai/corso/src/internal/connector/support"
"github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/tester"
"github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/control"
"github.com/alcionai/corso/src/pkg/selectors" "github.com/alcionai/corso/src/pkg/selectors"
@ -128,3 +130,37 @@ func driveItem(name string, path string, isFile bool) models.DriveItemable {
return item return item
} }
type SharePointPagesSuite struct {
suite.Suite
}
func TestSharePointPagesSuite(t *testing.T) {
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorSharePointTests)
suite.Run(t, new(SharePointPagesSuite))
}
func (suite *SharePointPagesSuite) TestCollectPages() {
ctx, flush := tester.NewContext()
defer flush()
t := suite.T()
siteID := tester.M365SiteID(t)
a := tester.NewM365Account(t)
account, err := a.M365Config()
require.NoError(t, err)
updateFunc := func(*support.ConnectorOperationStatus) {
t.Log("Updater Called ")
}
updater := &MockUpdater{UpdateState: updateFunc}
col, err := collectPages(ctx, account, nil, account.AzureTenantID, siteID, updater, control.Options{})
assert.NoError(t, err)
assert.NotEmpty(t, col)
}