Use tester suite wrapper in cli package (#2593)
## 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 - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup ## Issue(s) * #2373 ## Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
6e0b9183b4
commit
cfc2b2a206
@ -39,7 +39,7 @@ var backupDataSets = []path.CategoryType{email, contacts, events}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type NoBackupExchangeIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -50,13 +50,11 @@ type NoBackupExchangeIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestNoBackupExchangeIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
suite.Run(t, &NoBackupExchangeIntegrationSuite{Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(NoBackupExchangeIntegrationSuite))
|
||||
tester.CorsoCLIBackupTests)})
|
||||
}
|
||||
|
||||
func (suite *NoBackupExchangeIntegrationSuite) SetupSuite() {
|
||||
@ -65,8 +63,6 @@ func (suite *NoBackupExchangeIntegrationSuite) SetupSuite() {
|
||||
|
||||
defer flush()
|
||||
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
suite.st = tester.NewPrefixedS3Storage(t)
|
||||
@ -123,7 +119,7 @@ func (suite *NoBackupExchangeIntegrationSuite) TestExchangeBackupListCmd_empty()
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type BackupExchangeIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -133,13 +129,11 @@ type BackupExchangeIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestBackupExchangeIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
suite.Run(t, &BackupExchangeIntegrationSuite{Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(BackupExchangeIntegrationSuite))
|
||||
tester.CorsoCLIBackupTests)})
|
||||
}
|
||||
|
||||
func (suite *BackupExchangeIntegrationSuite) SetupSuite() {
|
||||
@ -148,8 +142,6 @@ func (suite *BackupExchangeIntegrationSuite) SetupSuite() {
|
||||
|
||||
defer flush()
|
||||
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
suite.st = tester.NewPrefixedS3Storage(t)
|
||||
@ -179,7 +171,9 @@ func (suite *BackupExchangeIntegrationSuite) TestExchangeBackupCmd() {
|
||||
for _, set := range backupDataSets {
|
||||
recorder.Reset()
|
||||
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
ctx = config.SetViper(ctx, suite.vpr)
|
||||
defer flush()
|
||||
@ -212,7 +206,7 @@ func (suite *BackupExchangeIntegrationSuite) TestExchangeBackupCmd() {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type PreparedBackupExchangeIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -224,18 +218,15 @@ type PreparedBackupExchangeIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestPreparedBackupExchangeIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
suite.Run(t, &PreparedBackupExchangeIntegrationSuite{Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(PreparedBackupExchangeIntegrationSuite))
|
||||
tester.CorsoCLIBackupTests)})
|
||||
}
|
||||
|
||||
func (suite *PreparedBackupExchangeIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
@ -309,7 +300,9 @@ func (suite *PreparedBackupExchangeIntegrationSuite) TestExchangeListCmd() {
|
||||
for _, set := range backupDataSets {
|
||||
suite.recorder.Reset()
|
||||
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
ctx = config.SetViper(ctx, suite.vpr)
|
||||
defer flush()
|
||||
@ -337,7 +330,9 @@ func (suite *PreparedBackupExchangeIntegrationSuite) TestExchangeListCmd_singleI
|
||||
for _, set := range backupDataSets {
|
||||
suite.recorder.Reset()
|
||||
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
ctx = config.SetViper(ctx, suite.vpr)
|
||||
defer flush()
|
||||
@ -366,7 +361,9 @@ func (suite *PreparedBackupExchangeIntegrationSuite) TestExchangeListCmd_singleI
|
||||
|
||||
func (suite *PreparedBackupExchangeIntegrationSuite) TestExchangeListCmd_badID() {
|
||||
for _, set := range backupDataSets {
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
ctx = config.SetViper(ctx, suite.vpr)
|
||||
defer flush()
|
||||
@ -389,7 +386,9 @@ func (suite *PreparedBackupExchangeIntegrationSuite) TestExchangeDetailsCmd() {
|
||||
for _, set := range backupDataSets {
|
||||
suite.recorder.Reset()
|
||||
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
ctx = config.SetViper(ctx, suite.vpr)
|
||||
defer flush()
|
||||
@ -427,8 +426,8 @@ func (suite *PreparedBackupExchangeIntegrationSuite) TestExchangeDetailsCmd() {
|
||||
continue
|
||||
}
|
||||
|
||||
t.Run(fmt.Sprintf("detail %d", i), func(t *testing.T) {
|
||||
assert.Contains(t, result, ent.ShortRef)
|
||||
suite.Run(fmt.Sprintf("detail %d", i), func() {
|
||||
assert.Contains(suite.T(), result, ent.ShortRef)
|
||||
})
|
||||
|
||||
i++
|
||||
@ -445,7 +444,7 @@ func (suite *PreparedBackupExchangeIntegrationSuite) TestExchangeDetailsCmd() {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type BackupDeleteExchangeIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -455,18 +454,17 @@ type BackupDeleteExchangeIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestBackupDeleteExchangeIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(BackupDeleteExchangeIntegrationSuite))
|
||||
suite.Run(t, &BackupDeleteExchangeIntegrationSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *BackupDeleteExchangeIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
|
||||
@ -14,11 +14,11 @@ import (
|
||||
)
|
||||
|
||||
type ExchangeSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestExchangeSuite(t *testing.T) {
|
||||
suite.Run(t, new(ExchangeSuite))
|
||||
suite.Run(t, &ExchangeSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *ExchangeSuite) TestAddExchangeCommands() {
|
||||
@ -49,7 +49,9 @@ func (suite *ExchangeSuite) TestAddExchangeCommands() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
cmd := &cobra.Command{Use: test.use}
|
||||
|
||||
c := addExchangeCommands(cmd)
|
||||
@ -94,7 +96,9 @@ func (suite *ExchangeSuite) TestValidateBackupCreateFlags() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
test.expect(t, validateExchangeBackupCreateFlags(test.user, test.data))
|
||||
})
|
||||
}
|
||||
@ -206,7 +210,9 @@ func (suite *ExchangeSuite) TestExchangeBackupCreateSelectors() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
sel := exchangeBackupCreateSelectors(test.user, test.data)
|
||||
assert.Equal(t, test.expectIncludeLen, len(sel.Includes))
|
||||
})
|
||||
@ -218,7 +224,9 @@ func (suite *ExchangeSuite) TestExchangeBackupDetailsSelectors() {
|
||||
defer flush()
|
||||
|
||||
for _, test := range testdata.ExchangeOptionDetailLookups {
|
||||
suite.T().Run(test.Name, func(t *testing.T) {
|
||||
suite.Run(test.Name, func() {
|
||||
t := suite.T()
|
||||
|
||||
output, err := runDetailsExchangeCmd(
|
||||
ctx,
|
||||
test.BackupGetter,
|
||||
@ -235,7 +243,9 @@ func (suite *ExchangeSuite) TestExchangeBackupDetailsSelectorsBadFormats() {
|
||||
defer flush()
|
||||
|
||||
for _, test := range testdata.BadExchangeOptionsFormats {
|
||||
suite.T().Run(test.Name, func(t *testing.T) {
|
||||
suite.Run(test.Name, func() {
|
||||
t := suite.T()
|
||||
|
||||
output, err := runDetailsExchangeCmd(
|
||||
ctx,
|
||||
test.BackupGetter,
|
||||
|
||||
@ -29,7 +29,7 @@ import (
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type NoBackupOneDriveIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -40,9 +40,13 @@ type NoBackupOneDriveIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestNoBackupOneDriveIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(NoBackupOneDriveIntegrationSuite))
|
||||
suite.Run(t, &NoBackupOneDriveIntegrationSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *NoBackupOneDriveIntegrationSuite) SetupSuite() {
|
||||
@ -51,8 +55,6 @@ func (suite *NoBackupOneDriveIntegrationSuite) SetupSuite() {
|
||||
|
||||
defer flush()
|
||||
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
suite.st = tester.NewPrefixedS3Storage(t)
|
||||
@ -114,7 +116,7 @@ func (suite *NoBackupOneDriveIntegrationSuite) TestOneDriveBackupListCmd_empty()
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type BackupDeleteOneDriveIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -125,18 +127,17 @@ type BackupDeleteOneDriveIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestBackupDeleteOneDriveIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(BackupDeleteOneDriveIntegrationSuite))
|
||||
suite.Run(t, &BackupDeleteOneDriveIntegrationSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIBackupTests),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *BackupDeleteOneDriveIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
|
||||
@ -13,11 +13,11 @@ import (
|
||||
)
|
||||
|
||||
type OneDriveSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestOneDriveSuite(t *testing.T) {
|
||||
suite.Run(t, new(OneDriveSuite))
|
||||
suite.Run(t, &OneDriveSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *OneDriveSuite) TestAddOneDriveCommands() {
|
||||
@ -48,7 +48,9 @@ func (suite *OneDriveSuite) TestAddOneDriveCommands() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
cmd := &cobra.Command{Use: test.use}
|
||||
|
||||
c := addOneDriveCommands(cmd)
|
||||
@ -82,8 +84,8 @@ func (suite *OneDriveSuite) TestValidateOneDriveBackupCreateFlags() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
test.expect(t, validateOneDriveBackupCreateFlags(test.user))
|
||||
suite.Run(test.name, func() {
|
||||
test.expect(suite.T(), validateOneDriveBackupCreateFlags(test.user))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -93,7 +95,9 @@ func (suite *OneDriveSuite) TestOneDriveBackupDetailsSelectors() {
|
||||
defer flush()
|
||||
|
||||
for _, test := range testdata.OneDriveOptionDetailLookups {
|
||||
suite.T().Run(test.Name, func(t *testing.T) {
|
||||
suite.Run(test.Name, func() {
|
||||
t := suite.T()
|
||||
|
||||
output, err := runDetailsOneDriveCmd(
|
||||
ctx,
|
||||
test.BackupGetter,
|
||||
@ -110,7 +114,9 @@ func (suite *OneDriveSuite) TestOneDriveBackupDetailsSelectorsBadFormats() {
|
||||
defer flush()
|
||||
|
||||
for _, test := range testdata.BadOneDriveOptionsFormats {
|
||||
suite.T().Run(test.Name, func(t *testing.T) {
|
||||
suite.Run(test.Name, func() {
|
||||
t := suite.T()
|
||||
|
||||
output, err := runDetailsOneDriveCmd(
|
||||
ctx,
|
||||
test.BackupGetter,
|
||||
|
||||
@ -29,7 +29,7 @@ import (
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type NoBackupSharePointIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -40,9 +40,10 @@ type NoBackupSharePointIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestNoBackupSharePointIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(NoBackupSharePointIntegrationSuite))
|
||||
suite.Run(t, &NoBackupSharePointIntegrationSuite{Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests, tester.CorsoCLIBackupTests)})
|
||||
}
|
||||
|
||||
func (suite *NoBackupSharePointIntegrationSuite) SetupSuite() {
|
||||
@ -51,8 +52,6 @@ func (suite *NoBackupSharePointIntegrationSuite) SetupSuite() {
|
||||
|
||||
defer flush()
|
||||
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
suite.st = tester.NewPrefixedS3Storage(t)
|
||||
@ -108,7 +107,7 @@ func (suite *NoBackupSharePointIntegrationSuite) TestSharePointBackupListCmd_emp
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type BackupDeleteSharePointIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -119,14 +118,16 @@ type BackupDeleteSharePointIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestBackupDeleteSharePointIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests)
|
||||
|
||||
suite.Run(t, new(BackupDeleteSharePointIntegrationSuite))
|
||||
suite.Run(t, &BackupDeleteSharePointIntegrationSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests, tester.CorsoCLIBackupTests),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *BackupDeleteSharePointIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// prepare common details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
|
||||
@ -16,11 +16,11 @@ import (
|
||||
)
|
||||
|
||||
type SharePointSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestSharePointSuite(t *testing.T) {
|
||||
suite.Run(t, new(SharePointSuite))
|
||||
suite.Run(t, &SharePointSuite{tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *SharePointSuite) TestAddSharePointCommands() {
|
||||
@ -51,7 +51,9 @@ func (suite *SharePointSuite) TestAddSharePointCommands() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
cmd := &cobra.Command{Use: test.use}
|
||||
|
||||
c := addSharePointCommands(cmd)
|
||||
@ -97,8 +99,8 @@ func (suite *SharePointSuite) TestValidateSharePointBackupCreateFlags() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
test.expect(t, validateSharePointBackupCreateFlags(test.site, test.weburl, nil))
|
||||
suite.Run(test.name, func() {
|
||||
test.expect(suite.T(), validateSharePointBackupCreateFlags(test.site, test.weburl, nil))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -191,7 +193,9 @@ func (suite *SharePointSuite) TestSharePointBackupCreateSelectors() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
@ -208,7 +212,9 @@ func (suite *SharePointSuite) TestSharePointBackupDetailsSelectors() {
|
||||
defer flush()
|
||||
|
||||
for _, test := range testdata.SharePointOptionDetailLookups {
|
||||
suite.T().Run(test.Name, func(t *testing.T) {
|
||||
suite.Run(test.Name, func() {
|
||||
t := suite.T()
|
||||
|
||||
output, err := runDetailsSharePointCmd(
|
||||
ctx,
|
||||
test.BackupGetter,
|
||||
@ -225,7 +231,9 @@ func (suite *SharePointSuite) TestSharePointBackupDetailsSelectorsBadFormats() {
|
||||
defer flush()
|
||||
|
||||
for _, test := range testdata.BadSharePointOptionsFormats {
|
||||
suite.T().Run(test.Name, func(t *testing.T) {
|
||||
suite.Run(test.Name, func() {
|
||||
t := suite.T()
|
||||
|
||||
output, err := runDetailsSharePointCmd(
|
||||
ctx,
|
||||
test.BackupGetter,
|
||||
|
||||
@ -8,14 +8,15 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/cli"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
)
|
||||
|
||||
type CLISuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestCLISuite(t *testing.T) {
|
||||
suite.Run(t, new(CLISuite))
|
||||
suite.Run(t, &CLISuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *CLISuite) TestAddCommands_noPanics() {
|
||||
|
||||
@ -31,11 +31,11 @@ const (
|
||||
)
|
||||
|
||||
type ConfigSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestConfigSuite(t *testing.T) {
|
||||
suite.Run(t, new(ConfigSuite))
|
||||
suite.Run(t, &ConfigSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *ConfigSuite) TestReadRepoConfigBasic() {
|
||||
@ -172,8 +172,8 @@ func (suite *ConfigSuite) TestMustMatchConfig() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
test.errCheck(t, mustMatchConfig(vpr, test.input))
|
||||
suite.Run(test.name, func() {
|
||||
test.errCheck(suite.T(), mustMatchConfig(vpr, test.input))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -183,20 +183,14 @@ func (suite *ConfigSuite) TestMustMatchConfig() {
|
||||
// ------------------------------------------------------------
|
||||
|
||||
type ConfigIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestConfigIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
suite.Run(t, &ConfigIntegrationSuite{Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
tester.CorsoCLIConfigTests)
|
||||
|
||||
suite.Run(t, new(ConfigIntegrationSuite))
|
||||
}
|
||||
|
||||
func (suite *ConfigIntegrationSuite) SetupSuite() {
|
||||
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLIConfigTests)})
|
||||
}
|
||||
|
||||
func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() {
|
||||
|
||||
@ -12,11 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type EnvSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestEnvSuite(t *testing.T) {
|
||||
suite.Run(t, new(EnvSuite))
|
||||
suite.Run(t, &EnvSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *EnvSuite) TestAddEnvCommands() {
|
||||
|
||||
@ -2,28 +2,31 @@ package print
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
)
|
||||
|
||||
type PrintUnitSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestPrintUnitSuite(t *testing.T) {
|
||||
suite.Run(t, new(PrintUnitSuite))
|
||||
suite.Run(t, &PrintUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *PrintUnitSuite) TestOnly() {
|
||||
t := suite.T()
|
||||
c := &cobra.Command{}
|
||||
// cannot use tester.NewContext() here: circular imports
|
||||
//nolint:forbidigo
|
||||
ctx := SetRootCmd(context.Background(), c)
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
ctx = SetRootCmd(ctx, c)
|
||||
assert.NoError(t, Only(ctx, nil))
|
||||
assert.True(t, c.SilenceUsage)
|
||||
}
|
||||
|
||||
@ -16,21 +16,15 @@ import (
|
||||
)
|
||||
|
||||
type S3IntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestS3IntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
suite.Run(t, &S3IntegrationSuite{Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIRepoTests)
|
||||
|
||||
suite.Run(t, new(S3IntegrationSuite))
|
||||
}
|
||||
|
||||
func (suite *S3IntegrationSuite) SetupSuite() {
|
||||
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
tester.CorsoCLIRepoTests)})
|
||||
}
|
||||
|
||||
func (suite *S3IntegrationSuite) TestInitS3Cmd() {
|
||||
@ -49,7 +43,9 @@ func (suite *S3IntegrationSuite) TestInitS3Cmd() {
|
||||
}
|
||||
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
@ -148,7 +144,9 @@ func (suite *S3IntegrationSuite) TestConnectS3Cmd() {
|
||||
}
|
||||
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type S3Suite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestS3Suite(t *testing.T) {
|
||||
suite.Run(t, new(S3Suite))
|
||||
suite.Run(t, &S3Suite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *S3Suite) TestAddS3Commands() {
|
||||
@ -33,7 +33,9 @@ func (suite *S3Suite) TestAddS3Commands() {
|
||||
{"connect s3", connectCommand, expectUse, s3ConnectCmd().Short, connectS3Cmd},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
cmd := &cobra.Command{Use: test.use}
|
||||
|
||||
c := addS3Commands(cmd)
|
||||
|
||||
@ -31,7 +31,7 @@ var (
|
||||
var backupDataSets = []path.CategoryType{email, contacts, events}
|
||||
|
||||
type RestoreExchangeIntegrationSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
acct account.Account
|
||||
st storage.Storage
|
||||
vpr *viper.Viper
|
||||
@ -42,13 +42,13 @@ type RestoreExchangeIntegrationSuite struct {
|
||||
}
|
||||
|
||||
func TestRestoreExchangeIntegrationSuite(t *testing.T) {
|
||||
tester.RunOnAny(
|
||||
t,
|
||||
tester.CorsoCITests,
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIRestoreTests)
|
||||
|
||||
suite.Run(t, new(RestoreExchangeIntegrationSuite))
|
||||
suite.Run(t, &RestoreExchangeIntegrationSuite{
|
||||
Suite: tester.NewIntegrationSuite(
|
||||
t,
|
||||
[][]string{tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs},
|
||||
tester.CorsoCLITests,
|
||||
tester.CorsoCLIRestoreTests),
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *RestoreExchangeIntegrationSuite) SetupSuite() {
|
||||
@ -57,8 +57,6 @@ func (suite *RestoreExchangeIntegrationSuite) SetupSuite() {
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
|
||||
|
||||
// aggregate required details
|
||||
suite.acct = tester.NewM365Account(t)
|
||||
suite.st = tester.NewPrefixedS3Storage(t)
|
||||
@ -119,7 +117,9 @@ func (suite *RestoreExchangeIntegrationSuite) SetupSuite() {
|
||||
|
||||
func (suite *RestoreExchangeIntegrationSuite) TestExchangeRestoreCmd() {
|
||||
for _, set := range backupDataSets {
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
ctx = config.SetViper(ctx, suite.vpr)
|
||||
|
||||
@ -143,7 +143,9 @@ func (suite *RestoreExchangeIntegrationSuite) TestExchangeRestoreCmd_badTimeFlag
|
||||
suite.T().Skip()
|
||||
}
|
||||
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext()
|
||||
ctx = config.SetViper(ctx, suite.vpr)
|
||||
|
||||
@ -176,7 +178,9 @@ func (suite *RestoreExchangeIntegrationSuite) TestExchangeRestoreCmd_badBoolFlag
|
||||
suite.T().Skip()
|
||||
}
|
||||
|
||||
suite.T().Run(set.String(), func(t *testing.T) {
|
||||
suite.Run(set.String(), func() {
|
||||
t := suite.T()
|
||||
|
||||
//nolint:forbidigo
|
||||
ctx := config.SetViper(context.Background(), suite.vpr)
|
||||
ctx, flush := tester.WithContext(ctx)
|
||||
|
||||
@ -12,11 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type ExchangeSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestExchangeSuite(t *testing.T) {
|
||||
suite.Run(t, new(ExchangeSuite))
|
||||
suite.Run(t, &ExchangeSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *ExchangeSuite) TestAddExchangeCommands() {
|
||||
@ -32,7 +32,9 @@ func (suite *ExchangeSuite) TestAddExchangeCommands() {
|
||||
{"restore exchange", restoreCommand, expectUse, exchangeRestoreCmd().Short, restoreExchangeCmd},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
cmd := &cobra.Command{Use: test.use}
|
||||
|
||||
c := addExchangeCommands(cmd)
|
||||
|
||||
@ -12,11 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type OneDriveSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestOneDriveSuite(t *testing.T) {
|
||||
suite.Run(t, new(OneDriveSuite))
|
||||
suite.Run(t, &OneDriveSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *OneDriveSuite) TestAddOneDriveCommands() {
|
||||
@ -32,7 +32,9 @@ func (suite *OneDriveSuite) TestAddOneDriveCommands() {
|
||||
{"restore onedrive", restoreCommand, expectUse, oneDriveRestoreCmd().Short, restoreOneDriveCmd},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
cmd := &cobra.Command{Use: test.use}
|
||||
|
||||
c := addOneDriveCommands(cmd)
|
||||
|
||||
@ -12,11 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type SharePointSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestSharePointSuite(t *testing.T) {
|
||||
suite.Run(t, new(SharePointSuite))
|
||||
suite.Run(t, &SharePointSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *SharePointSuite) TestAddSharePointCommands() {
|
||||
@ -32,7 +32,9 @@ func (suite *SharePointSuite) TestAddSharePointCommands() {
|
||||
{"restore onedrive", restoreCommand, expectUse, sharePointRestoreCmd().Short, restoreSharePointCmd},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
cmd := &cobra.Command{Use: test.use}
|
||||
|
||||
c := addSharePointCommands(cmd)
|
||||
|
||||
@ -8,15 +8,16 @@ import (
|
||||
|
||||
"github.com/alcionai/corso/src/cli/utils"
|
||||
"github.com/alcionai/corso/src/internal/common"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
)
|
||||
|
||||
type ExchangeUtilsSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestExchangeUtilsSuite(t *testing.T) {
|
||||
suite.Run(t, new(ExchangeUtilsSuite))
|
||||
suite.Run(t, &ExchangeUtilsSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *ExchangeUtilsSuite) TestValidateRestoreFlags() {
|
||||
@ -50,8 +51,8 @@ func (suite *ExchangeUtilsSuite) TestValidateRestoreFlags() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
test.expect(t, utils.ValidateExchangeRestoreFlags(test.backupID, test.opts))
|
||||
suite.Run(test.name, func() {
|
||||
test.expect(suite.T(), utils.ValidateExchangeRestoreFlags(test.backupID, test.opts))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -300,9 +301,9 @@ func (suite *ExchangeUtilsSuite) TestIncludeExchangeRestoreDataSelectors() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
sel := utils.IncludeExchangeRestoreDataSelectors(test.opts)
|
||||
assert.Len(t, sel.Includes, test.expectIncludeLen)
|
||||
assert.Len(suite.T(), sel.Includes, test.expectIncludeLen)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -361,11 +362,11 @@ func (suite *ExchangeUtilsSuite) TestAddExchangeInclude() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
sel := selectors.NewExchangeRestore(nil)
|
||||
// no return, mutates sel as a side effect
|
||||
utils.AddExchangeInclude(sel, test.folders, test.items, eisc)
|
||||
assert.Len(t, sel.Includes, test.expectIncludeLen)
|
||||
assert.Len(suite.T(), sel.Includes, test.expectIncludeLen)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -477,10 +478,10 @@ func (suite *ExchangeUtilsSuite) TestFilterExchangeRestoreInfoSelectors() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
sel := selectors.NewExchangeRestore(nil)
|
||||
utils.FilterExchangeRestoreInfoSelectors(sel, test.opts)
|
||||
assert.Len(t, sel.Filters, test.expectFilterLen)
|
||||
assert.Len(suite.T(), sel.Filters, test.expectFilterLen)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,14 +7,15 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/cli/utils"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
)
|
||||
|
||||
type OneDriveUtilsSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestOneDriveUtilsSuite(t *testing.T) {
|
||||
suite.Run(t, new(OneDriveUtilsSuite))
|
||||
suite.Run(t, &OneDriveUtilsSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *OneDriveUtilsSuite) TestIncludeOneDriveRestoreDataSelectors() {
|
||||
@ -88,9 +89,9 @@ func (suite *OneDriveUtilsSuite) TestIncludeOneDriveRestoreDataSelectors() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
sel := utils.IncludeOneDriveRestoreDataSelectors(test.opts)
|
||||
assert.Len(t, sel.Includes, test.expectIncludeLen)
|
||||
assert.Len(suite.T(), sel.Includes, test.expectIncludeLen)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,14 +7,15 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/cli/utils"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
)
|
||||
|
||||
type SharePointUtilsSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestSharePointUtilsSuite(t *testing.T) {
|
||||
suite.Run(t, new(SharePointUtilsSuite))
|
||||
suite.Run(t, &SharePointUtilsSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
// Tests selector build for SharePoint properly
|
||||
@ -181,9 +182,9 @@ func (suite *SharePointUtilsSuite) TestIncludeSharePointRestoreDataSelectors() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
sel := utils.IncludeSharePointRestoreDataSelectors(test.opts)
|
||||
assert.Len(t, sel.Includes, test.expectIncludeLen)
|
||||
assert.Len(suite.T(), sel.Includes, test.expectIncludeLen)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,15 +6,16 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
)
|
||||
|
||||
type CliUtilsSuite struct {
|
||||
suite.Suite
|
||||
tester.Suite
|
||||
}
|
||||
|
||||
func TestCliUtilsSuite(t *testing.T) {
|
||||
suite.Run(t, new(CliUtilsSuite))
|
||||
suite.Run(t, &CliUtilsSuite{Suite: tester.NewUnitSuite(t)})
|
||||
}
|
||||
|
||||
func (suite *CliUtilsSuite) TestRequireProps() {
|
||||
@ -75,7 +76,9 @@ func (suite *CliUtilsSuite) TestSplitFoldersIntoContainsAndPrefix() {
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
c, p := splitFoldersIntoContainsAndPrefix(test.input)
|
||||
assert.ElementsMatch(t, test.expectC, c, "contains set")
|
||||
assert.ElementsMatch(t, test.expectP, p, "prefix set")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user