diff --git a/src/internal/m365/service/groups/restore.go b/src/internal/m365/service/groups/restore.go index a233535e2..9a94a921b 100644 --- a/src/internal/m365/service/groups/restore.go +++ b/src/internal/m365/service/groups/restore.go @@ -18,6 +18,7 @@ import ( "github.com/alcionai/corso/src/pkg/control" "github.com/alcionai/corso/src/pkg/count" "github.com/alcionai/corso/src/pkg/fault" + "github.com/alcionai/corso/src/pkg/logger" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/services/m365/api" ) @@ -103,6 +104,9 @@ func ConsumeRestoreCollections( control.DefaultRestoreContainerName(dttm.HumanReadableDriveItem), errs, ctr) + case path.ChannelMessagesCategory: + // Message cannot be restored as of now using Graph API. + logger.Ctx(ctx).Debug("Skipping restore for channel messages") default: return nil, clues.New("data category not supported"). With("category", category). diff --git a/src/internal/m365/service/groups/restore_test.go b/src/internal/m365/service/groups/restore_test.go new file mode 100644 index 000000000..d87000fc5 --- /dev/null +++ b/src/internal/m365/service/groups/restore_test.go @@ -0,0 +1,60 @@ +package groups + +import ( + "testing" + + "github.com/alcionai/clues" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + "github.com/alcionai/corso/src/internal/common/idname" + "github.com/alcionai/corso/src/internal/data" + "github.com/alcionai/corso/src/internal/data/mock" + "github.com/alcionai/corso/src/internal/operations/inject" + "github.com/alcionai/corso/src/internal/tester" + "github.com/alcionai/corso/src/pkg/fault" + "github.com/alcionai/corso/src/pkg/path" + "github.com/alcionai/corso/src/pkg/services/m365/api" +) + +type GroupsUnitSuite struct { + tester.Suite +} + +func TestGroupsUnitSuite(t *testing.T) { + suite.Run(t, &GroupsUnitSuite{Suite: tester.NewUnitSuite(t)}) +} + +func (suite *GroupsUnitSuite) TestConsumeRestoreCollections_noErrorOnGroups() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + rcc := inject.RestoreConsumerConfig{} + pth, err := path.Builder{}. + Append("General"). + ToDataLayerPath( + "t", + "g", + path.GroupsService, + path.ChannelMessagesCategory, + false) + require.NoError(t, err, clues.ToCore(err)) + + dcs := []data.RestoreCollection{ + mock.Collection{Path: pth}, + } + + _, err = ConsumeRestoreCollections( + ctx, + rcc, + api.Client{}, + idname.NewCache(map[string]string{}), + dcs, + nil, + fault.New(false), + nil) + assert.NoError(t, err, "Groups Channels restore") +} diff --git a/src/pkg/storage/testdata/storage.go b/src/pkg/storage/testdata/storage.go index 6f1eab5f6..227a959bb 100644 --- a/src/pkg/storage/testdata/storage.go +++ b/src/pkg/storage/testdata/storage.go @@ -56,7 +56,7 @@ func NewFilesystemStorage(t tester.TestT) storage.Storage { now := tester.LogTimeOfTest(t) repoPath := filepath.Join(t.TempDir(), now) - err := os.MkdirAll(repoPath, 0700) + err := os.MkdirAll(repoPath, 0o700) require.NoErrorf(t, err, "creating filesystem repo: %+v", clues.ToCore(err)) t.Logf("testing at filesystem repo [%s]", repoPath)