Update test helpers for groups backup (#4126)

This still is not complete, but this fixes a few places in the test suite helpers where we did not accommodate for groups.

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [x] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* https://github.com/alcionai/corso/issues/3990

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abin Simon 2023-08-31 15:25:50 +05:30 committed by GitHub
parent b6ecfd8806
commit 81b7416806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 17 deletions

View File

@ -48,13 +48,13 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_groupsBasic() {
var (
mb = evmock.NewBus()
sel = selectors.NewGroupsBackup([]string{suite.its.site.ID})
sel = selectors.NewGroupsBackup([]string{suite.its.group.ID})
opts = control.DefaultOptions()
)
sel.Include(
selTD.GroupsBackupLibraryFolderScope(sel),
selTD.GroupsBackupChannelScope(sel))
selTD.GroupsBackupChannelScope(sel)) // FIXME: channel backups are not ready
bo, bod := prepNewTestBackupOp(t, ctx, mb, sel.Selector, opts, version.Backup)
defer bod.close(t, ctx)
@ -79,7 +79,7 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_groupsExtensions() {
var (
mb = evmock.NewBus()
sel = selectors.NewGroupsBackup([]string{suite.its.site.ID})
sel = selectors.NewGroupsBackup([]string{suite.its.group.ID})
opts = control.DefaultOptions()
tenID = tconfig.M365TenantID(t)
svc = path.GroupsService

View File

@ -133,8 +133,12 @@ func prepNewTestBackupOp(
bod.sw = store.NewWrapper(bod.kms)
connectorResource := resource.Users
if sel.Service == selectors.ServiceSharePoint {
switch sel.Service {
case selectors.ServiceSharePoint:
connectorResource = resource.Sites
case selectors.ServiceGroups:
connectorResource = resource.Groups
}
bod.ctrl, bod.sel = ControllerWithSelector(
@ -521,6 +525,8 @@ func toDataLayerPath(
p, err = pb.ToDataLayerOneDrivePath(tenant, resourceOwner, isItem)
case path.SharePointService:
p, err = pb.ToDataLayerSharePointPath(tenant, resourceOwner, category, isItem)
case path.GroupsService:
p, err = pb.ToDataLayerPath(tenant, resourceOwner, service, category, false)
default:
err = clues.New(fmt.Sprintf("unknown service: %s", service))
}
@ -575,6 +581,11 @@ type ids struct {
DriveRootFolderID string
}
type gids struct {
ID string
RootSite ids
}
type intgTesterSetup struct {
ac api.Client
gockAC api.Client
@ -582,7 +593,7 @@ type intgTesterSetup struct {
secondaryUser ids
site ids
secondarySite ids
group ids
group gids
}
func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
@ -652,22 +663,26 @@ func siteIDs(t *testing.T, id string, ac api.Client) ids {
return r
}
func groupIDs(t *testing.T, id string, ac api.Client) ids {
r := ids{ID: id}
func groupIDs(t *testing.T, id string, ac api.Client) gids {
ctx, flush := tester.NewContext(t)
defer flush()
// ctx, flush := tester.NewContext(t)
// defer flush()
r := gids{ID: id}
// TODO: get default site drive info
// drive, err := ac.Groups().GetDefaultDrive(ctx, id)
// require.NoError(t, err, clues.ToCore(err))
site, err := ac.Groups().GetRootSite(ctx, id)
require.NoError(t, err, clues.ToCore(err))
// r.DriveID = ptr.Val(drive.GetId())
r.RootSite.ID = ptr.Val(site.GetId())
// driveRootFolder, err := ac.Drives().GetRootFolder(ctx, r.DriveID)
// require.NoError(t, err, clues.ToCore(err))
drive, err := ac.Sites().GetDefaultDrive(ctx, r.RootSite.ID)
require.NoError(t, err, clues.ToCore(err))
// r.DriveRootFolderID = ptr.Val(driveRootFolder.GetId())
r.RootSite.DriveID = ptr.Val(drive.GetId())
driveRootFolder, err := ac.Drives().GetRootFolder(ctx, r.RootSite.DriveID)
require.NoError(t, err, clues.ToCore(err))
r.RootSite.DriveRootFolderID = ptr.Val(driveRootFolder.GetId())
return r
}

View File

@ -108,8 +108,12 @@ func prepNewTestRestoreOp(
rod.sw = store.NewWrapper(rod.kms)
connectorResource := resource.Users
if sel.Service == selectors.ServiceSharePoint {
switch sel.Service {
case selectors.ServiceSharePoint:
connectorResource = resource.Sites
case selectors.ServiceGroups:
connectorResource = resource.Groups
}
rod.ctrl, rod.sel = ControllerWithSelector(