Some minor test cleanup (#1194)

## Description

* switch up email restore/backup test slightly to cover multiple folders
* remove multi-folder mail backup, now overlaps with the above
* remove stale TODO
* remove unused struct field
* factor out common struct

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [x] 🤖 Test
- [ ] 💻 CI/Deployment
- [x] 🐹 Trivial/Minor

## Issue(s)

* #913 

## Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2022-10-18 10:24:07 -07:00 committed by GitHub
parent 3e3c21ab1b
commit b752d1da8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 68 deletions

View File

@ -156,6 +156,12 @@ type colInfo struct {
items []itemInfo
}
type restoreBackupInfo struct {
name string
service path.ServiceType
collections []colInfo
}
func attachmentEqual(
expected models.Attachmentable,
got models.Attachmentable,

View File

@ -450,21 +450,14 @@ func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() {
}
}
// TestRestoreAndBackup
func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() {
bodyText := "This email has some text. However, all the text is on the same line."
subjectText := "Test message for restore"
table := []struct {
name string
service path.ServiceType
collections []colInfo
expectedRestoreFolders int
}{
table := []restoreBackupInfo{
{
name: "EmailsWithAttachments",
service: path.ExchangeService,
expectedRestoreFolders: 1,
name: "EmailsWithAttachments",
service: path.ExchangeService,
collections: []colInfo{
{
pathElements: []string{"Inbox"},
@ -489,9 +482,8 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() {
},
},
{
name: "MultipleEmailsSingleFolder",
service: path.ExchangeService,
expectedRestoreFolders: 1,
name: "MultipleEmailsMultipleFolders",
service: path.ExchangeService,
collections: []colInfo{
{
pathElements: []string{"Inbox"},
@ -505,6 +497,12 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() {
),
lookupKey: subjectText + "-1",
},
},
},
{
pathElements: []string{"Work"},
category: path.EmailCategory,
items: []itemInfo{
{
name: "someencodeditemID2",
data: mockconnector.GetMockMessageWithBodyBytes(
@ -717,66 +715,17 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreAndBackup() {
checkCollections(t, totalItems, expectedData, dcs)
status = backupGC.AwaitStatus()
// TODO(ashmrtn): This will need to change when the restore layout is
// updated.
assert.Equal(t, totalItems, status.ObjectCount, "status.ObjectCount")
assert.Equal(t, totalItems, status.Successful, "status.Successful")
})
}
}
// TestMultiFolderBackupDifferentNames
func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames() {
bodyText := "This email has some text. However, all the text is on the same line."
subjectText := "Test message for restore"
table := []struct {
name string
service path.ServiceType
category path.CategoryType
// Each collection will be restored separately, creating multiple folders to
// backup later.
collections []colInfo
}{
table := []restoreBackupInfo{
{
name: "Email",
service: path.ExchangeService,
category: path.EmailCategory,
collections: []colInfo{
{
pathElements: []string{"Inbox"},
category: path.EmailCategory,
items: []itemInfo{
{
name: "someencodeditemID",
data: mockconnector.GetMockMessageWithBodyBytes(
subjectText+"-1",
bodyText+" 1.",
),
lookupKey: subjectText + "-1",
},
},
},
{
pathElements: []string{"Archive"},
category: path.EmailCategory,
items: []itemInfo{
{
name: "someencodeditemID2",
data: mockconnector.GetMockMessageWithBodyBytes(
subjectText+"-2",
bodyText+" 2.",
),
lookupKey: subjectText + "-2",
},
},
},
},
},
{
name: "Contacts",
service: path.ExchangeService,
category: path.ContactsCategory,
name: "Contacts",
service: path.ExchangeService,
collections: []colInfo{
{
pathElements: []string{"Work"},
@ -803,9 +752,8 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames
},
},
{
name: "Events",
service: path.ExchangeService,
category: path.EventsCategory,
name: "Events",
service: path.ExchangeService,
collections: []colInfo{
{
pathElements: []string{"Work"},