This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into beta-page-connector
- Loading branch information
Showing
11 changed files
with
331 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package sharepoint | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/alcionai/corso/src/pkg/backup/details" | ||
) | ||
|
||
// sharePointPageInfo propagates metadata from the SharePoint Page data type | ||
// into searchable content. | ||
// Page Details: https://learn.microsoft.com/en-us/graph/api/resources/sitepage?view=graph-rest-beta | ||
func sharePointPageInfo(page SitePageable, size int64) *details.SharePointInfo { | ||
var ( | ||
name, webURL string | ||
created, modified time.Time | ||
) | ||
|
||
if page.GetTitle() != nil { | ||
name = *page.GetTitle() | ||
} | ||
|
||
if page.GetWebUrl() != nil { | ||
webURL = *page.GetWebUrl() | ||
} | ||
|
||
if page.GetCreatedDateTime() != nil { | ||
created = *page.GetCreatedDateTime() | ||
} | ||
|
||
if page.GetLastModifiedDateTime() != nil { | ||
modified = *page.GetLastModifiedDateTime() | ||
} | ||
|
||
return &details.SharePointInfo{ | ||
ItemType: details.SharePointItem, | ||
ItemName: name, | ||
Created: created, | ||
Modified: modified, | ||
WebURL: webURL, | ||
Size: size, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package sharepoint | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/alcionai/corso/src/pkg/backup/details" | ||
) | ||
|
||
func (suite *SharePointInfoSuite) TestSharePointInfo_Pages() { | ||
tests := []struct { | ||
name string | ||
pageAndDeets func() (SitePageable, *details.SharePointInfo) | ||
}{ | ||
{ | ||
name: "Empty Page", | ||
pageAndDeets: func() (SitePageable, *details.SharePointInfo) { | ||
deets := &details.SharePointInfo{ItemType: details.SharePointItem} | ||
return NewSitePage(), deets | ||
}, | ||
}, | ||
{ | ||
name: "Only Name", | ||
pageAndDeets: func() (SitePageable, *details.SharePointInfo) { | ||
title := "Blank Page" | ||
sPage := NewSitePage() | ||
sPage.SetTitle(&title) | ||
deets := &details.SharePointInfo{ | ||
ItemType: details.SharePointItem, | ||
ItemName: title, | ||
} | ||
|
||
return sPage, deets | ||
}, | ||
}, | ||
} | ||
for _, test := range tests { | ||
suite.T().Run(test.name, func(t *testing.T) { | ||
paged, expected := test.pageAndDeets() | ||
info := sharePointPageInfo(paged, 0) | ||
assert.Equal(t, expected.ItemType, info.ItemType) | ||
assert.Equal(t, expected.ItemName, info.ItemName) | ||
assert.Equal(t, expected.WebURL, info.WebURL) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.