centralizes details command processing in the cli --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #2025
69 lines
1.4 KiB
Go
69 lines
1.4 KiB
Go
package backup
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/alcionai/clues"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/alcionai/corso/src/cli/utils/testdata"
|
|
"github.com/alcionai/corso/src/internal/tester"
|
|
dtd "github.com/alcionai/corso/src/pkg/backup/details/testdata"
|
|
"github.com/alcionai/corso/src/pkg/control"
|
|
"github.com/alcionai/corso/src/pkg/path"
|
|
"github.com/alcionai/corso/src/pkg/selectors"
|
|
)
|
|
|
|
type BackupUnitSuite struct {
|
|
tester.Suite
|
|
}
|
|
|
|
func TestBackupUnitSuite(t *testing.T) {
|
|
suite.Run(t, &BackupUnitSuite{Suite: tester.NewUnitSuite(t)})
|
|
}
|
|
|
|
func (suite *BackupUnitSuite) TestGenericDetailsCore() {
|
|
t := suite.T()
|
|
|
|
expected := append(
|
|
append(
|
|
dtd.GetItemsForVersion(
|
|
t,
|
|
path.ExchangeService,
|
|
path.EmailCategory,
|
|
0,
|
|
-1),
|
|
dtd.GetItemsForVersion(
|
|
t,
|
|
path.ExchangeService,
|
|
path.EventsCategory,
|
|
0,
|
|
-1)...),
|
|
dtd.GetItemsForVersion(
|
|
t,
|
|
path.ExchangeService,
|
|
path.ContactsCategory,
|
|
0,
|
|
-1)...)
|
|
|
|
ctx, flush := tester.NewContext(t)
|
|
defer flush()
|
|
|
|
bg := testdata.VersionedBackupGetter{
|
|
Details: dtd.GetDetailsSetForVersion(t, 0),
|
|
}
|
|
|
|
sel := selectors.NewExchangeBackup([]string{"user-id"})
|
|
sel.Include(sel.AllData())
|
|
|
|
output, err := genericDetailsCore(
|
|
ctx,
|
|
bg,
|
|
"backup-ID",
|
|
sel.Selector,
|
|
control.DefaultOptions())
|
|
assert.NoError(t, err, clues.ToCore(err))
|
|
assert.ElementsMatch(t, expected, output.Entries)
|
|
}
|