Just pass in config to helpers (#4843)
Instead of passing in many parameters and assembling that in the helper function, just pass in the config. --- #### 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 - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup #### Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
4b64faef70
commit
ddabfc3b3a
@ -676,22 +676,11 @@ func runBackupAndCompare(
|
||||
func runRestoreBackupTest(
|
||||
t *testing.T,
|
||||
test restoreBackupInfo,
|
||||
tenant string,
|
||||
resourceOwners []string,
|
||||
opts control.Options,
|
||||
restoreCfg control.RestoreConfig,
|
||||
cfg stub.ConfigInfo,
|
||||
) {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
cfg := stub.ConfigInfo{
|
||||
Opts: opts,
|
||||
Service: test.service,
|
||||
Tenant: tenant,
|
||||
ResourceOwners: resourceOwners,
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
totalItems, totalKopiaItems, collections, expectedData, err := stub.GetCollectionsAndExpected(
|
||||
cfg,
|
||||
test.collections,
|
||||
@ -721,22 +710,11 @@ func runRestoreBackupTest(
|
||||
func runRestoreTestWithVersion(
|
||||
t *testing.T,
|
||||
test restoreBackupInfoMultiVersion,
|
||||
tenant string,
|
||||
resourceOwners []string,
|
||||
opts control.Options,
|
||||
restoreCfg control.RestoreConfig,
|
||||
cfg stub.ConfigInfo,
|
||||
) {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
cfg := stub.ConfigInfo{
|
||||
Opts: opts,
|
||||
Service: test.service,
|
||||
Tenant: tenant,
|
||||
ResourceOwners: resourceOwners,
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
totalItems, _, collections, _, err := stub.GetCollectionsAndExpected(
|
||||
cfg,
|
||||
test.collectionsPrevious,
|
||||
@ -758,22 +736,11 @@ func runRestoreTestWithVersion(
|
||||
func runRestoreBackupTestVersions(
|
||||
t *testing.T,
|
||||
test restoreBackupInfoMultiVersion,
|
||||
tenant string,
|
||||
resourceOwners []string,
|
||||
opts control.Options,
|
||||
restoreCfg control.RestoreConfig,
|
||||
cfg stub.ConfigInfo,
|
||||
) {
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
cfg := stub.ConfigInfo{
|
||||
Opts: opts,
|
||||
Service: test.service,
|
||||
Tenant: tenant,
|
||||
ResourceOwners: resourceOwners,
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
totalItems, _, collections, _, err := stub.GetCollectionsAndExpected(
|
||||
cfg,
|
||||
test.collectionsPrevious,
|
||||
@ -1076,13 +1043,15 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup_core() {
|
||||
|
||||
for _, test := range table {
|
||||
suite.Run(test.name, func() {
|
||||
runRestoreBackupTest(
|
||||
suite.T(),
|
||||
test,
|
||||
suite.ctrl.tenant,
|
||||
[]string{suite.user},
|
||||
control.DefaultOptions(),
|
||||
control.DefaultRestoreConfig(dttm.SafeForTesting))
|
||||
cfg := stub.ConfigInfo{
|
||||
Tenant: suite.ctrl.tenant,
|
||||
ResourceOwners: []string{suite.user},
|
||||
Service: test.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: control.DefaultRestoreConfig(dttm.SafeForTesting),
|
||||
}
|
||||
|
||||
runRestoreBackupTest(suite.T(), test, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1301,13 +1270,15 @@ func (suite *ControllerIntegrationSuite) TestRestoreAndBackup_largeMailAttachmen
|
||||
restoreCfg := control.DefaultRestoreConfig(dttm.SafeForTesting)
|
||||
restoreCfg.IncludePermissions = true
|
||||
|
||||
runRestoreBackupTest(
|
||||
suite.T(),
|
||||
test,
|
||||
suite.ctrl.tenant,
|
||||
[]string{suite.user},
|
||||
control.DefaultOptions(),
|
||||
restoreCfg)
|
||||
cfg := stub.ConfigInfo{
|
||||
Tenant: suite.ctrl.tenant,
|
||||
ResourceOwners: []string{suite.user},
|
||||
Service: test.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
runRestoreBackupTest(suite.T(), test, cfg)
|
||||
}
|
||||
|
||||
func (suite *ControllerIntegrationSuite) TestBackup_CreatesPrefixCollections() {
|
||||
|
||||
@ -17,6 +17,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/collection/drive/metadata"
|
||||
odConsts "github.com/alcionai/corso/src/internal/m365/service/onedrive/consts"
|
||||
"github.com/alcionai/corso/src/internal/m365/service/onedrive/stub"
|
||||
m365Stub "github.com/alcionai/corso/src/internal/m365/stub"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
@ -508,13 +509,15 @@ func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
|
||||
restoreCfg.OnCollision = control.Replace
|
||||
restoreCfg.IncludePermissions = true
|
||||
|
||||
runRestoreBackupTestVersions(
|
||||
t,
|
||||
testData,
|
||||
suite.Tenant(),
|
||||
[]string{suite.ResourceOwner()},
|
||||
control.DefaultOptions(),
|
||||
restoreCfg)
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Service: testData.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
runRestoreBackupTestVersions(t, testData, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -756,13 +759,15 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
restoreCfg.OnCollision = control.Replace
|
||||
restoreCfg.IncludePermissions = true
|
||||
|
||||
runRestoreBackupTestVersions(
|
||||
t,
|
||||
testData,
|
||||
suite.Tenant(),
|
||||
[]string{suite.ResourceOwner()},
|
||||
control.DefaultOptions(),
|
||||
restoreCfg)
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Service: testData.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
runRestoreBackupTestVersions(t, testData, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -845,13 +850,15 @@ func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
|
||||
restoreCfg.OnCollision = control.Replace
|
||||
restoreCfg.IncludePermissions = false
|
||||
|
||||
runRestoreBackupTestVersions(
|
||||
t,
|
||||
testData,
|
||||
suite.Tenant(),
|
||||
[]string{suite.ResourceOwner()},
|
||||
control.DefaultOptions(),
|
||||
restoreCfg)
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Service: testData.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
runRestoreBackupTestVersions(t, testData, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1049,13 +1056,15 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
|
||||
restoreCfg.OnCollision = control.Replace
|
||||
restoreCfg.IncludePermissions = true
|
||||
|
||||
runRestoreBackupTestVersions(
|
||||
t,
|
||||
testData,
|
||||
suite.Tenant(),
|
||||
[]string{suite.ResourceOwner()},
|
||||
control.DefaultOptions(),
|
||||
restoreCfg)
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Service: testData.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
runRestoreBackupTestVersions(t, testData, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1243,13 +1252,15 @@ func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion
|
||||
restoreCfg.OnCollision = control.Replace
|
||||
restoreCfg.IncludePermissions = true
|
||||
|
||||
runRestoreBackupTestVersions(
|
||||
t,
|
||||
testData,
|
||||
suite.Tenant(),
|
||||
[]string{suite.ResourceOwner()},
|
||||
control.DefaultOptions(),
|
||||
restoreCfg)
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Service: testData.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
runRestoreBackupTestVersions(t, testData, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1358,13 +1369,15 @@ func testRestoreFolderNamedFolderRegression(
|
||||
restoreCfg := control.DefaultRestoreConfig(dttm.SafeForTesting)
|
||||
restoreCfg.IncludePermissions = true
|
||||
|
||||
runRestoreTestWithVersion(
|
||||
t,
|
||||
testData,
|
||||
suite.Tenant(),
|
||||
[]string{suite.ResourceOwner()},
|
||||
control.DefaultOptions(),
|
||||
restoreCfg)
|
||||
cfg := m365Stub.ConfigInfo{
|
||||
Tenant: suite.Tenant(),
|
||||
ResourceOwners: []string{suite.ResourceOwner()},
|
||||
Service: testData.service,
|
||||
Opts: control.DefaultOptions(),
|
||||
RestoreCfg: restoreCfg,
|
||||
}
|
||||
|
||||
runRestoreTestWithVersion(t, testData, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user