Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

GC: Backup: SharePoint: Test Fetch/Get Functions #2182

Merged
merged 6 commits into from
Jan 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions src/internal/connector/sharepoint/site_page_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package sharepoint

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"github.com/alcionai/corso/src/internal/tester"
"github.com/alcionai/corso/src/pkg/account"
)

type SharePointPageSuite struct {
suite.Suite

creds account.M365Config
}

func (suite *SharePointPageSuite) SetupSuite() {
t := suite.T()
a := tester.NewM365Account(t)
m365, err := a.M365Config()
require.NoError(t, err)

suite.creds = m365
}

func TestSharePointPageSuite(t *testing.T) {
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorSharePointTests)
suite.Run(t, new(SharePointPageSuite))
}

func (suite *SharePointPageSuite) TestFetchPages() {
ctx, flush := tester.NewContext()
defer flush()

t := suite.T()
siteID := tester.M365SiteID(t)
service, err := createTestService(suite.creds)
require.NoError(t, err)

pgs, err := fetchPages(ctx, *service, siteID)
assert.NoError(t, err)
require.NotNil(t, pgs)
assert.NotZero(t, len(pgs))

for _, entry := range pgs {
t.Logf("id: %s\t name: %s\n", entry.id, entry.name)
}
}

func (suite *SharePointPageSuite) TestGetSitePage() {
ctx, flush := tester.NewContext()
defer flush()

t := suite.T()
siteID := tester.M365SiteID(t)

service, err := createTestService(suite.creds)
require.NoError(t, err)
tuples, err := fetchPages(ctx, *service, siteID)
require.NoError(t, err)
require.NotNil(t, tuples)

jobs := []string{tuples[0].id}
pages, err := GetSitePage(ctx, service, siteID, jobs)
assert.NoError(t, err)
assert.NotEmpty(t, pages)
}