tetst fixes and touchups (#1983)
## Does this PR need a docs update or release note? - [x] ⛔ No ## Type of change - [x] 🤖 Test ## Issue(s) * #1966 ## Test Plan - [x] 💚 E2E
This commit is contained in:
parent
1586ed927b
commit
753ede5a1a
@ -35,7 +35,7 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/store"
|
||||
)
|
||||
|
||||
const incrementalsDestFolderPrefix = "incrementals_ci_"
|
||||
const incrementalsDestContainerPrefix = "incrementals_ci_"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// helpers
|
||||
@ -638,10 +638,10 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
path.EmailCategory: exchange.MetadataFileNames(path.EmailCategory),
|
||||
path.ContactsCategory: exchange.MetadataFileNames(path.ContactsCategory),
|
||||
}
|
||||
folder1 = fmt.Sprintf("%s%d_%s", incrementalsDestFolderPrefix, 1, now)
|
||||
folder2 = fmt.Sprintf("%s%d_%s", incrementalsDestFolderPrefix, 2, now)
|
||||
folder3 = fmt.Sprintf("%s%d_%s", incrementalsDestFolderPrefix, 3, now)
|
||||
folderRename = fmt.Sprintf("%s%d_%s", incrementalsDestFolderPrefix, 4, now)
|
||||
container1 = fmt.Sprintf("%s%d_%s", incrementalsDestContainerPrefix, 1, now)
|
||||
container2 = fmt.Sprintf("%s%d_%s", incrementalsDestContainerPrefix, 2, now)
|
||||
container3 = fmt.Sprintf("%s%d_%s", incrementalsDestContainerPrefix, 3, now)
|
||||
containerRename = fmt.Sprintf("%s%d_%s", incrementalsDestContainerPrefix, 4, now)
|
||||
)
|
||||
|
||||
m365, err := acct.M365Config()
|
||||
@ -650,12 +650,10 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
gc, err := connector.NewGraphConnector(ctx, acct, connector.Users)
|
||||
require.NoError(t, err)
|
||||
|
||||
// generate 3 new folders with two items each.
|
||||
// Only the first two folders will be part of the initial backup and
|
||||
// incrementals. The third folder will be introduced partway through
|
||||
// the changes.
|
||||
// generate 2 new containers with two items each.
|
||||
// A third container will be introduced partway through the changes.
|
||||
// This should be enough to cover most delta actions, since moving one
|
||||
// folder into another generates a delta for both addition and deletion.
|
||||
// container into another generates a delta for both addition and deletion.
|
||||
type contDeets struct {
|
||||
containerID string
|
||||
deets *details.Details
|
||||
@ -686,17 +684,15 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
path.EmailCategory: {
|
||||
dbf: mailDBF,
|
||||
dests: map[string]contDeets{
|
||||
folder1: {},
|
||||
folder2: {},
|
||||
folder3: {},
|
||||
container1: {},
|
||||
container2: {},
|
||||
},
|
||||
},
|
||||
path.ContactsCategory: {
|
||||
dbf: contactDBF,
|
||||
dests: map[string]contDeets{
|
||||
folder1: {},
|
||||
folder2: {},
|
||||
folder3: {},
|
||||
container1: {},
|
||||
container2: {},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -740,11 +736,14 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
}
|
||||
}
|
||||
|
||||
// use the new folders here
|
||||
// container3 and containerRename don't exist yet. Those will get created
|
||||
// later on during the tests. Putting their identifiers into the selector
|
||||
// at this point is harmless.
|
||||
containers := []string{container1, container2, container3, containerRename}
|
||||
sel := selectors.NewExchangeBackup(users)
|
||||
sel.Include(
|
||||
sel.MailFolders(users, []string{folder1, folder2}, selectors.PrefixMatch()),
|
||||
sel.ContactFolders(users, []string{folder1, folder2}, selectors.PrefixMatch()),
|
||||
sel.MailFolders(users, containers, selectors.PrefixMatch()),
|
||||
sel.ContactFolders(users, containers, selectors.PrefixMatch()),
|
||||
)
|
||||
|
||||
bo, _, kw, ms, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, ffs)
|
||||
@ -774,16 +773,16 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
name: "move an email folder to a subfolder",
|
||||
updateUserData: func(t *testing.T) {
|
||||
// contacts cannot be sufoldered; this is an email-only change
|
||||
toFolder := dataset[path.EmailCategory].dests[folder1].containerID
|
||||
fromFolder := dataset[path.EmailCategory].dests[folder2].containerID
|
||||
toContainer := dataset[path.EmailCategory].dests[container1].containerID
|
||||
fromContainer := dataset[path.EmailCategory].dests[container2].containerID
|
||||
|
||||
body := msuser.NewItemMailFoldersItemMovePostRequestBody()
|
||||
body.SetDestinationId(&toFolder)
|
||||
body.SetDestinationId(&toContainer)
|
||||
|
||||
_, err := gc.Service.
|
||||
Client().
|
||||
UsersById(suite.user).
|
||||
MailFoldersById(fromFolder).
|
||||
MailFoldersById(fromContainer).
|
||||
Move().
|
||||
Post(ctx, body, nil)
|
||||
require.NoError(t, err)
|
||||
@ -795,19 +794,19 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
name: "delete a folder",
|
||||
updateUserData: func(t *testing.T) {
|
||||
for category, d := range dataset {
|
||||
folderID := d.dests[folder2].containerID
|
||||
containerID := d.dests[container2].containerID
|
||||
cli := gc.Service.Client().UsersById(suite.user)
|
||||
|
||||
switch category {
|
||||
case path.EmailCategory:
|
||||
require.NoError(
|
||||
t,
|
||||
cli.MailFoldersById(folderID).Delete(ctx, nil),
|
||||
cli.MailFoldersById(containerID).Delete(ctx, nil),
|
||||
"deleting an email folder")
|
||||
case path.ContactsCategory:
|
||||
require.NoError(
|
||||
t,
|
||||
cli.ContactFoldersById(folderID).Delete(ctx, nil),
|
||||
cli.ContactFoldersById(containerID).Delete(ctx, nil),
|
||||
"deleting a contacts folder")
|
||||
}
|
||||
}
|
||||
@ -818,52 +817,80 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
{
|
||||
name: "add a new folder",
|
||||
updateUserData: func(t *testing.T) {
|
||||
// instead of working through graph, we'll mutate he selector to now
|
||||
// include an additional folder. Since all backups in this test have
|
||||
// avoided folder3, it should appear as a new backup.
|
||||
sel = selectors.NewExchangeBackup(users)
|
||||
sel.Include(
|
||||
sel.MailFolders(users, []string{folder1, folder2, folder3}, selectors.PrefixMatch()),
|
||||
sel.ContactFolders(users, []string{folder1, folder2, folder3}, selectors.PrefixMatch()),
|
||||
)
|
||||
for category, gen := range dataset {
|
||||
deets := generateContainerOfItems(
|
||||
t,
|
||||
ctx,
|
||||
gc,
|
||||
path.ExchangeService,
|
||||
category,
|
||||
selectors.NewExchangeRestore(users).Selector,
|
||||
m365.AzureTenantID, suite.user, container3,
|
||||
2,
|
||||
gen.dbf)
|
||||
|
||||
qp := graph.QueryParams{
|
||||
Category: category,
|
||||
ResourceOwner: suite.user,
|
||||
Credentials: m365,
|
||||
}
|
||||
cr, err := exchange.PopulateExchangeContainerResolver(ctx, qp)
|
||||
require.NoError(t, err, "populating %s container resolver", category)
|
||||
|
||||
p, err := path.FromDataLayerPath(deets.Entries[0].RepoRef, true)
|
||||
require.NoError(t, err)
|
||||
|
||||
id, ok := cr.PathInCache(p.Folder())
|
||||
require.True(t, ok, "dir %s found in %s cache", p.Folder(), category)
|
||||
|
||||
dataset[category].dests[container3] = contDeets{id, deets}
|
||||
}
|
||||
},
|
||||
itemsRead: 0,
|
||||
itemsWritten: 0,
|
||||
itemsRead: 4,
|
||||
itemsWritten: 4,
|
||||
},
|
||||
{
|
||||
name: "rename a folder",
|
||||
updateUserData: func(t *testing.T) {
|
||||
for category, d := range dataset {
|
||||
folderID := d.dests[folder3].containerID
|
||||
containerID := d.dests[container3].containerID
|
||||
cli := gc.Service.Client().UsersById(suite.user)
|
||||
|
||||
// copy the container info, since both names should
|
||||
// reference the same container by id. Though the
|
||||
// details refs won't line up, so those get deleted.
|
||||
d.dests[containerRename] = contDeets{
|
||||
containerID: d.dests[container3].containerID,
|
||||
deets: nil,
|
||||
}
|
||||
|
||||
switch category {
|
||||
case path.EmailCategory:
|
||||
cmf := cli.MailFoldersById(folderID)
|
||||
cmf := cli.MailFoldersById(containerID)
|
||||
body, err := cmf.Get(ctx, nil)
|
||||
require.NoError(t, err, "getting mail folder")
|
||||
body.SetDisplayName(&folderRename)
|
||||
body.SetDisplayName(&containerRename)
|
||||
_, err = cmf.Patch(ctx, body, nil)
|
||||
require.NoError(t, err, "updating mail folder name")
|
||||
|
||||
case path.ContactsCategory:
|
||||
ccf := cli.ContactFoldersById(folderID)
|
||||
ccf := cli.ContactFoldersById(containerID)
|
||||
body, err := ccf.Get(ctx, nil)
|
||||
require.NoError(t, err, "getting contact folder")
|
||||
body.SetDisplayName(&folderRename)
|
||||
body.SetDisplayName(&containerRename)
|
||||
_, err = ccf.Patch(ctx, body, nil)
|
||||
require.NoError(t, err, "updating contact folder name")
|
||||
}
|
||||
}
|
||||
},
|
||||
itemsRead: 0,
|
||||
itemsWritten: 0,
|
||||
itemsWritten: 4,
|
||||
},
|
||||
{
|
||||
name: "add a new item",
|
||||
updateUserData: func(t *testing.T) {
|
||||
for category, d := range dataset {
|
||||
folderID := d.dests[folder1].containerID
|
||||
containerID := d.dests[container1].containerID
|
||||
cli := gc.Service.Client().UsersById(suite.user)
|
||||
|
||||
switch category {
|
||||
@ -872,7 +899,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
body, err := support.CreateMessageFromBytes(itemData)
|
||||
require.NoError(t, err, "transforming mail bytes to messageable")
|
||||
|
||||
_, err = cli.MailFoldersById(folderID).Messages().Post(ctx, body, nil)
|
||||
_, err = cli.MailFoldersById(containerID).Messages().Post(ctx, body, nil)
|
||||
require.NoError(t, err, "posting email item")
|
||||
|
||||
case path.ContactsCategory:
|
||||
@ -880,7 +907,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
body, err := support.CreateContactFromBytes(itemData)
|
||||
require.NoError(t, err, "transforming contact bytes to contactable")
|
||||
|
||||
_, err = cli.ContactFoldersById(folderID).Contacts().Post(ctx, body, nil)
|
||||
_, err = cli.ContactFoldersById(containerID).Contacts().Post(ctx, body, nil)
|
||||
require.NoError(t, err, "posting contact item")
|
||||
}
|
||||
}
|
||||
@ -892,12 +919,12 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
name: "delete an existing item",
|
||||
updateUserData: func(t *testing.T) {
|
||||
for category, d := range dataset {
|
||||
folderID := d.dests[folder1].containerID
|
||||
containerID := d.dests[container1].containerID
|
||||
cli := gc.Service.Client().UsersById(suite.user)
|
||||
|
||||
switch category {
|
||||
case path.EmailCategory:
|
||||
ids, _, _, err := exchange.FetchMessageIDsFromDirectory(ctx, gc.Service, suite.user, folderID, "")
|
||||
ids, _, _, err := exchange.FetchMessageIDsFromDirectory(ctx, gc.Service, suite.user, containerID, "")
|
||||
require.NoError(t, err, "getting message ids")
|
||||
require.NotEmpty(t, ids, "message ids in folder")
|
||||
|
||||
@ -905,7 +932,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
||||
require.NoError(t, err, "deleting email item: %s", support.ConnectorStackErrorTrace(err))
|
||||
|
||||
case path.ContactsCategory:
|
||||
ids, _, _, err := exchange.FetchContactIDsFromDirectory(ctx, gc.Service, suite.user, folderID, "")
|
||||
ids, _, _, err := exchange.FetchContactIDsFromDirectory(ctx, gc.Service, suite.user, containerID, "")
|
||||
require.NoError(t, err, "getting contact ids")
|
||||
require.NotEmpty(t, ids, "contact ids in folder")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user