Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
GC: Backup: CI: Stabilize Iterator test (#1079)
Browse files Browse the repository at this point in the history
## Description
CI test timing during times of high activity. Reduced test suite to cover Inbox and adjusted outputs accordingly. 
<!-- Insert PR description-->

## Type of change

- [x] 🐛 Bugfix

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
*closes  #1078<issue>

## Test Plan

- [x] ⚡ Unit test
  • Loading branch information
Danny authored Oct 7, 2022
1 parent 0724db9 commit a5140d2
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions src/internal/connector/exchange/iterators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,19 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
var (
ctx = context.Background()
t = suite.T()
mailScope, contactScope, eventScope selectors.ExchangeScope
mailScope, contactScope, eventScope []selectors.ExchangeScope
userID = tester.M365UserID(t)
sel = selectors.NewExchangeBackup()
service = loadService(t)
)

sel.Include(sel.Users([]string{userID}))

eb, err := sel.ToExchangeBackup()
require.NoError(suite.T(), err)

scopes := eb.Scopes()

for _, scope := range scopes {
if scope.IncludesCategory(selectors.ExchangeContactFolder) {
contactScope = scope
}
contactScope = sel.ContactFolders([]string{userID}, []string{DefaultContactFolder})
eventScope = sel.EventCalendars([]string{userID}, []string{DefaultCalendar})
mailScope = sel.MailFolders([]string{userID}, []string{DefaultMailFolder})

if scope.IncludesCategory(selectors.ExchangeMail) {
mailScope = scope
}

if scope.IncludesCategory(selectors.ExchangeEvent) {
eventScope = scope
}
}
eb.Include(contactScope, eventScope, mailScope)

tests := []struct {
name string
Expand All @@ -113,7 +100,7 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
name: "Mail Iterative Check",
queryFunction: GetAllMessagesForUser,
iterativeFunction: IterateSelectAllDescendablesForCollections,
scope: mailScope,
scope: mailScope[0],
transformer: models.CreateMessageCollectionResponseFromDiscriminatorValue,
folderNames: map[string]struct{}{
DefaultMailFolder: {},
Expand All @@ -123,41 +110,40 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
name: "Contacts Iterative Check",
queryFunction: GetAllContactsForUser,
iterativeFunction: IterateSelectAllDescendablesForCollections,
scope: contactScope,
scope: contactScope[0],
transformer: models.CreateContactFromDiscriminatorValue,
}, {
name: "Contact Folder Traversal",
queryFunction: GetAllContactFolderNamesForUser,
iterativeFunction: IterateSelectAllContactsForCollections,
scope: contactScope,
scope: contactScope[0],
transformer: models.CreateContactFolderCollectionResponseFromDiscriminatorValue,
}, {
name: "Events Iterative Check",
queryFunction: GetAllCalendarNamesForUser,
iterativeFunction: IterateSelectAllEventsFromCalendars,
scope: eventScope,
scope: eventScope[0],
transformer: models.CreateCalendarCollectionResponseFromDiscriminatorValue,
}, {
name: "Folder Iterative Check Mail",
queryFunction: GetAllFolderNamesForUser,
iterativeFunction: IterateFilterContainersForCollections,
scope: mailScope,
scope: mailScope[0],
transformer: models.CreateMailFolderCollectionResponseFromDiscriminatorValue,
folderNames: map[string]struct{}{
DefaultMailFolder: {},
"Sent Items": {},
"Deleted Items": {},
},
}, {
name: "Folder Iterative Check Contacts",
queryFunction: GetAllContactFolderNamesForUser,
iterativeFunction: IterateFilterContainersForCollections,
scope: contactScope,
scope: contactScope[0],
transformer: models.CreateContactFolderCollectionResponseFromDiscriminatorValue,
},
}
for _, test := range tests {
suite.T().Run(test.name, func(t *testing.T) {
service := loadService(t)
response, err := test.queryFunction(ctx, service, userID)
require.NoError(t, err)
// Create Iterator
Expand Down Expand Up @@ -201,8 +187,8 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {

for _, c := range collections {
require.NotEmpty(t, c.FullPath().Folder())

folder := c.FullPath().Folder()

if _, ok := test.folderNames[folder]; ok {
delete(test.folderNames, folder)
}
Expand Down

0 comments on commit a5140d2

Please sign in to comment.