corso/src/cli/backup/help_e2e_test.go
Keepers 43c9ad4a01
clean up cli e2e tests (#3068)
deduplicate some e2e boilerplate setup.
Also, transitions exchange e2e tests from an in-
test loop over categories, to a well-defined test
func per category.  The former design doesn't
play well with go test --run ./testName, and
causes all tests to run even if they don't match
the string.

---

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

- [x]  No

#### Type of change

- [x] 🤖 Supportability/Tests
- [x] 🧹 Tech Debt/Cleanup

#### Test Plan

- [x] 💚 E2E
2023-04-13 07:15:30 +00:00

54 lines
1.2 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"
"github.com/alcionai/corso/src/pkg/account"
"github.com/alcionai/corso/src/pkg/control"
"github.com/alcionai/corso/src/pkg/repository"
"github.com/alcionai/corso/src/pkg/storage"
)
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 = tester.NewM365Account(t)
st = tester.NewPrefixedS3Storage(t)
recorder = strings.Builder{}
)
cfg, err := st.S3Config()
require.NoError(t, err, clues.ToCore(err))
force := map[string]string{
tester.TestCfgAccountProvider: "M365",
tester.TestCfgStorageProvider: "S3",
tester.TestCfgPrefix: cfg.Prefix,
}
vpr, cfgFP := tester.MakeTempTestConfigClone(t, force)
ctx = config.SetViper(ctx, vpr)
repo, err := repository.Initialize(ctx, acct, st, control.Options{})
require.NoError(t, err, clues.ToCore(err))
return acct, st, repo, vpr, recorder, cfgFP
}