GC Restore: Event pipeline not working [FIX] (#780)
Bug Fix to ensure E2E testing. Test suite expanded.
This commit is contained in:
parent
35c6f2b6b0
commit
6640d42aac
@ -508,3 +508,77 @@ func (suite *ExchangeServiceSuite) TestGetRestoreContainer() {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestRestoreExchangeObject verifies path.Category usage for restored objects
|
||||
func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
ctx := context.Background()
|
||||
t := suite.T()
|
||||
userID := tester.M365UserID(t)
|
||||
service := loadService(t)
|
||||
now := time.Now()
|
||||
tests := []struct {
|
||||
name string
|
||||
bytes []byte
|
||||
category path.CategoryType
|
||||
cleanupFunc func(graph.Service, string, string) error
|
||||
destination func() string
|
||||
}{
|
||||
{
|
||||
name: "Test Mail",
|
||||
bytes: mockconnector.GetMockMessageBytes("Restore Exchange Object"),
|
||||
category: path.EmailCategory,
|
||||
cleanupFunc: DeleteMailFolder,
|
||||
destination: func() string {
|
||||
folderName := "TestRestoreMailObject: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateMailFolder(suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
|
||||
return *folder.GetId()
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test Contact",
|
||||
bytes: mockconnector.GetMockContactBytes("Test_Omega"),
|
||||
category: path.ContactsCategory,
|
||||
cleanupFunc: DeleteContactFolder,
|
||||
destination: func() string {
|
||||
folderName := "TestRestoreContactObject: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateContactFolder(suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
|
||||
return *folder.GetId()
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test Events",
|
||||
bytes: mockconnector.GetMockEventBytes("Restored Event Object"),
|
||||
category: path.EventsCategory,
|
||||
cleanupFunc: DeleteCalendar,
|
||||
destination: func() string {
|
||||
calendarName := "TestRestoreEventObject: " + common.FormatSimpleDateTime(now)
|
||||
calendar, err := CreateCalendar(suite.es, userID, calendarName)
|
||||
require.NoError(t, err)
|
||||
|
||||
return *calendar.GetId()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
destination := test.destination()
|
||||
err := RestoreExchangeObject(
|
||||
ctx,
|
||||
test.bytes,
|
||||
test.category,
|
||||
control.Copy,
|
||||
service,
|
||||
destination,
|
||||
userID,
|
||||
)
|
||||
assert.NoError(t, err)
|
||||
cleanupError := test.cleanupFunc(service, userID, destination)
|
||||
assert.NoError(t, cleanupError)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,19 +353,12 @@ func RestoreExchangeObject(
|
||||
service graph.Service,
|
||||
destination, user string,
|
||||
) error {
|
||||
var setting optionIdentifier
|
||||
|
||||
switch category {
|
||||
case path.EmailCategory, path.ContactsCategory:
|
||||
setting = categoryToOptionIdentifier(category)
|
||||
default:
|
||||
return fmt.Errorf("type: %s not supported for exchange restore", category)
|
||||
}
|
||||
|
||||
if policy != control.Copy {
|
||||
return fmt.Errorf("restore policy: %s not supported", policy)
|
||||
}
|
||||
|
||||
setting := categoryToOptionIdentifier(category)
|
||||
|
||||
switch setting {
|
||||
case messages:
|
||||
return RestoreMailMessage(ctx, bits, service, control.Copy, destination, user)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user