corso/src/cli/backup/help_e2e_test.go
ashmrtn 1e126bd2af
Allow setting retention parameters on repo init (#3903)
Take in information about retention so that
when the repo is initialized we can configure
retention

Not currently exposed by CLI layer

**Requires changing the interface for repo
init so SDK consumers will require changes**

---

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

* #3519

#### Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
2023-07-28 15:39:17 +00:00

61 lines
1.4 KiB
Go

package backup_test
import (
"context"
"strings"
"testing"
"github.com/alcionai/clues"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
"github.com/alcionai/corso/src/cli/config"
"github.com/alcionai/corso/src/internal/tester/tconfig"
"github.com/alcionai/corso/src/pkg/account"
"github.com/alcionai/corso/src/pkg/control"
ctrlRepo "github.com/alcionai/corso/src/pkg/control/repository"
"github.com/alcionai/corso/src/pkg/repository"
"github.com/alcionai/corso/src/pkg/storage"
"github.com/alcionai/corso/src/pkg/storage/testdata"
)
func prepM365Test(
t *testing.T,
ctx context.Context, //revive:disable-line:context-as-argument
) (
account.Account,
storage.Storage,
repository.Repository,
*viper.Viper,
strings.Builder,
string,
) {
var (
acct = tconfig.NewM365Account(t)
st = testdata.NewPrefixedS3Storage(t)
recorder = strings.Builder{}
)
cfg, err := st.S3Config()
require.NoError(t, err, clues.ToCore(err))
force := map[string]string{
tconfig.TestCfgAccountProvider: "M365",
tconfig.TestCfgStorageProvider: "S3",
tconfig.TestCfgPrefix: cfg.Prefix,
}
vpr, cfgFP := tconfig.MakeTempTestConfigClone(t, force)
ctx = config.SetViper(ctx, vpr)
repo, err := repository.Initialize(
ctx,
acct,
st,
control.DefaultOptions(),
ctrlRepo.Retention{})
require.NoError(t, err, clues.ToCore(err))
return acct, st, repo, vpr, recorder, cfgFP
}