No tester errors 2 (#2005)

## Type of change

- [x] 🐹 Trivial/Minor
This commit is contained in:
Keepers 2023-01-03 14:35:56 -07:00 committed by GitHub
parent 07faa7bffb
commit ce1f4406f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 192 additions and 421 deletions

View File

@ -50,13 +50,11 @@ type NoBackupExchangeIntegrationSuite struct {
}
func TestNoBackupExchangeIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIBackupTests)
suite.Run(t, new(NoBackupExchangeIntegrationSuite))
}
@ -67,10 +65,7 @@ func (suite *NoBackupExchangeIntegrationSuite) SetupSuite() {
defer flush()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)
@ -138,13 +133,11 @@ type BackupExchangeIntegrationSuite struct {
}
func TestBackupExchangeIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIBackupTests)
suite.Run(t, new(BackupExchangeIntegrationSuite))
}
@ -155,10 +148,7 @@ func (suite *BackupExchangeIntegrationSuite) SetupSuite() {
defer flush()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)
@ -234,23 +224,18 @@ type PreparedBackupExchangeIntegrationSuite struct {
}
func TestPreparedBackupExchangeIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIBackupTests)
suite.Run(t, new(PreparedBackupExchangeIntegrationSuite))
}
func (suite *PreparedBackupExchangeIntegrationSuite) SetupSuite() {
t := suite.T()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)
@ -471,23 +456,18 @@ type BackupDeleteExchangeIntegrationSuite struct {
}
func TestBackupDeleteExchangeIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIBackupTests)
suite.Run(t, new(BackupDeleteExchangeIntegrationSuite))
}
func (suite *BackupDeleteExchangeIntegrationSuite) SetupSuite() {
t := suite.T()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)

View File

@ -40,13 +40,7 @@ type NoBackupOneDriveIntegrationSuite struct {
}
func TestNoBackupOneDriveIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests)
suite.Run(t, new(NoBackupOneDriveIntegrationSuite))
}
@ -57,10 +51,7 @@ func (suite *NoBackupOneDriveIntegrationSuite) SetupSuite() {
defer flush()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)
@ -128,23 +119,18 @@ type BackupDeleteOneDriveIntegrationSuite struct {
}
func TestBackupDeleteOneDriveIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIBackupTests)
suite.Run(t, new(BackupDeleteOneDriveIntegrationSuite))
}
func (suite *BackupDeleteOneDriveIntegrationSuite) SetupSuite() {
t := suite.T()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)

View File

@ -40,13 +40,7 @@ type NoBackupSharePointIntegrationSuite struct {
}
func TestNoBackupSharePointIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests)
suite.Run(t, new(NoBackupSharePointIntegrationSuite))
}
@ -57,10 +51,7 @@ func (suite *NoBackupSharePointIntegrationSuite) SetupSuite() {
defer flush()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)
@ -128,23 +119,14 @@ type BackupDeleteSharePointIntegrationSuite struct {
}
func TestBackupDeleteSharePointIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIBackupTests,
); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoCITests, tester.CorsoCLITests, tester.CorsoCLIBackupTests)
suite.Run(t, new(BackupDeleteSharePointIntegrationSuite))
}
func (suite *BackupDeleteSharePointIntegrationSuite) SetupSuite() {
t := suite.T()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// prepare common details
suite.acct = tester.NewM365Account(t)

View File

@ -187,21 +187,16 @@ type ConfigIntegrationSuite struct {
}
func TestConfigIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLIConfigTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIConfigTests)
suite.Run(t, new(ConfigIntegrationSuite))
}
func (suite *ConfigIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
}
func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() {

View File

@ -20,22 +20,17 @@ type S3IntegrationSuite struct {
}
func TestS3IntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIRepoTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIRepoTests)
suite.Run(t, new(S3IntegrationSuite))
}
func (suite *S3IntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
}
func (suite *S3IntegrationSuite) TestInitS3Cmd() {

View File

@ -42,13 +42,11 @@ type RestoreExchangeIntegrationSuite struct {
}
func TestRestoreExchangeIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoCLITests,
tester.CorsoCLIRestoreTests,
); err != nil {
t.Skip(err)
}
tester.CorsoCLIRestoreTests)
suite.Run(t, new(RestoreExchangeIntegrationSuite))
}
@ -59,11 +57,7 @@ func (suite *RestoreExchangeIntegrationSuite) SetupSuite() {
ctx, flush := tester.NewContext()
defer flush()
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs,
)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
// aggregate required details
suite.acct = tester.NewM365Account(t)

View File

@ -28,12 +28,10 @@ type ConnectorDataCollectionIntegrationSuite struct {
}
func TestConnectorDataCollectionIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(t,
tester.CorsoCITests,
tester.CorsoConnectorDataCollectionTests,
); err != nil {
t.Skip(err)
}
)
suite.Run(t, new(ConnectorDataCollectionIntegrationSuite))
}
@ -42,11 +40,12 @@ func (suite *ConnectorDataCollectionIntegrationSuite) SetupSuite() {
ctx, flush := tester.NewContext()
defer flush()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvVars(suite.T(), tester.M365AcctCredEnvs...)
suite.connector = loadConnector(ctx, suite.T(), AllResources)
suite.user = tester.M365UserID(suite.T())
suite.site = tester.M365SiteID(suite.T())
tester.LogTimeOfTest(suite.T())
}
@ -260,12 +259,10 @@ type ConnectorCreateSharePointCollectionIntegrationSuite struct {
}
func TestConnectorCreateSharePointCollectionIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoConnectorCreateSharePointCollectionTests,
); err != nil {
t.Skip(err)
}
tester.CorsoConnectorCreateSharePointCollectionTests)
suite.Run(t, new(ConnectorCreateSharePointCollectionIntegrationSuite))
}
@ -274,10 +271,11 @@ func (suite *ConnectorCreateSharePointCollectionIntegrationSuite) SetupSuite() {
ctx, flush := tester.NewContext()
defer flush()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs)
suite.connector = loadConnector(ctx, suite.T(), Sites)
suite.user = tester.M365UserID(suite.T())
tester.LogTimeOfTest(suite.T())
}

View File

@ -209,19 +209,16 @@ type DataCollectionsIntegrationSuite struct {
}
func TestDataCollectionsIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoConnectorCreateExchangeCollectionTests,
); err != nil {
t.Skip(err)
}
tester.CorsoConnectorCreateExchangeCollectionTests)
suite.Run(t, new(DataCollectionsIntegrationSuite))
}
func (suite *DataCollectionsIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs)
suite.user = tester.M365UserID(suite.T())
suite.site = tester.M365SiteID(suite.T())

View File

@ -26,25 +26,20 @@ type ExchangeServiceSuite struct {
}
func TestExchangeServiceSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorExchangeTests,
); err != nil {
t.Skip(err)
}
tester.CorsoGraphConnectorExchangeTests)
suite.Run(t, new(ExchangeServiceSuite))
}
func (suite *ExchangeServiceSuite) SetupSuite() {
t := suite.T()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.M365AcctCredEnvs)
a := tester.NewM365Account(t)
require.NoError(t, err)
m365, err := a.M365Config()
require.NoError(t, err)

View File

@ -17,13 +17,11 @@ type CacheResolverSuite struct {
}
func TestCacheResolverIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorExchangeTests,
); err != nil {
t.Skip(err)
}
tester.CorsoGraphConnectorExchangeTests)
suite.Run(t, new(CacheResolverSuite))
}
@ -31,12 +29,9 @@ func TestCacheResolverIntegrationSuite(t *testing.T) {
func (suite *CacheResolverSuite) SetupSuite() {
t := suite.T()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.M365AcctCredEnvs)
a := tester.NewM365Account(t)
require.NoError(t, err)
m365, err := a.M365Config()
require.NoError(t, err)

View File

@ -22,13 +22,11 @@ type ExchangeIteratorSuite struct {
}
func TestExchangeIteratorSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorExchangeTests,
); err != nil {
t.Skip(err)
}
tester.CorsoGraphConnectorExchangeTests)
suite.Run(t, new(ExchangeIteratorSuite))
}

View File

@ -29,15 +29,22 @@ type MailFolderCacheIntegrationSuite struct {
gs graph.Servicer
}
func TestMailFolderCacheIntegrationSuite(t *testing.T) {
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorExchangeTests)
suite.Run(t, new(MailFolderCacheIntegrationSuite))
}
func (suite *MailFolderCacheIntegrationSuite) SetupSuite() {
t := suite.T()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.M365AcctCredEnvs)
a := tester.NewM365Account(t)
require.NoError(t, err)
m365, err := a.M365Config()
require.NoError(t, err)
@ -47,18 +54,6 @@ func (suite *MailFolderCacheIntegrationSuite) SetupSuite() {
suite.gs = service
}
func TestMailFolderCacheIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorExchangeTests,
); err != nil {
t.Skip(err)
}
suite.Run(t, new(MailFolderCacheIntegrationSuite))
}
func (suite *MailFolderCacheIntegrationSuite) TestDeltaFetch() {
suite.T().Skipf("Test depends on hardcoded folder names. Skipping till that is fixed")

View File

@ -138,13 +138,11 @@ type GraphConnectorIntegrationSuite struct {
}
func TestGraphConnectorIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorExchangeTests,
); err != nil {
t.Skip(err)
}
tester.CorsoGraphConnectorExchangeTests)
suite.Run(t, new(GraphConnectorIntegrationSuite))
}
@ -153,10 +151,11 @@ func (suite *GraphConnectorIntegrationSuite) SetupSuite() {
ctx, flush := tester.NewContext()
defer flush()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs)
suite.connector = loadConnector(ctx, suite.T(), Users)
suite.user = tester.M365UserID(suite.T())
tester.LogTimeOfTest(suite.T())
}

View File

@ -21,12 +21,10 @@ type OneDriveSuite struct {
}
func TestOneDriveDriveSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoOneDriveTests,
); err != nil {
t.Skip(err)
}
tester.CorsoOneDriveTests)
suite.Run(t, new(OneDriveSuite))
}

View File

@ -35,13 +35,11 @@ func (suite *ItemIntegrationSuite) Adapter() *msgraphsdk.GraphRequestAdapter {
}
func TestItemIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorTests,
tester.CorsoGraphConnectorOneDriveTests,
); err != nil {
t.Skip(err)
}
tester.CorsoGraphConnectorOneDriveTests)
suite.Run(t, new(ItemIntegrationSuite))
}
@ -52,11 +50,9 @@ func (suite *ItemIntegrationSuite) SetupSuite() {
ctx, flush := tester.NewContext()
defer flush()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.M365AcctCredEnvs)
a := tester.NewM365Account(t)
m365, err := a.M365Config()
require.NoError(t, err)

View File

@ -26,13 +26,10 @@ func (suite *SharePointSuite) SetupSuite() {
}
func TestSharePointSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoGraphConnectorSharePointTests,
); err != nil {
t.Skip(err)
}
tester.CorsoGraphConnectorSharePointTests)
suite.Run(t, new(SharePointSuite))
}

View File

@ -19,10 +19,7 @@ type EventsIntegrationSuite struct {
}
func TestMetricsIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(tester.CorsoCITests); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoCITests)
suite.Run(t, new(EventsIntegrationSuite))
}

View File

@ -59,19 +59,16 @@ type WrapperIntegrationSuite struct {
}
func TestWrapperIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoKopiaWrapperTests,
); err != nil {
t.Skip(err)
}
tester.CorsoKopiaWrapperTests)
suite.Run(t, new(WrapperIntegrationSuite))
}
func (suite *WrapperIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
}
func (suite *WrapperIntegrationSuite) TestRepoExistsError() {

View File

@ -63,19 +63,16 @@ type ModelStoreIntegrationSuite struct {
}
func TestModelStoreIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoModelStoreTests,
); err != nil {
t.Skip(err)
}
tester.CorsoModelStoreTests)
suite.Run(t, new(ModelStoreIntegrationSuite))
}
func (suite *ModelStoreIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
}
func (suite *ModelStoreIntegrationSuite) SetupTest() {
@ -712,19 +709,16 @@ type ModelStoreRegressionSuite struct {
}
func TestModelStoreRegressionSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoModelStoreTests,
); err != nil {
t.Skip(err)
}
tester.CorsoModelStoreTests)
suite.Run(t, new(ModelStoreRegressionSuite))
}
func (suite *ModelStoreRegressionSuite) SetupSuite() {
_, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
}
// TODO(ashmrtn): Make a mock of whatever controls the handle to kopia so we can

View File

@ -148,19 +148,16 @@ type KopiaIntegrationSuite struct {
}
func TestKopiaIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoKopiaWrapperTests,
); err != nil {
t.Skip(err)
}
tester.CorsoKopiaWrapperTests)
suite.Run(t, new(KopiaIntegrationSuite))
}
func (suite *KopiaIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory(
testTenant,
@ -509,19 +506,16 @@ type KopiaSimpleRepoIntegrationSuite struct {
}
func TestKopiaSimpleRepoIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoKopiaWrapperTests,
); err != nil {
t.Skip(err)
}
tester.CorsoKopiaWrapperTests)
suite.Run(t, new(KopiaSimpleRepoIntegrationSuite))
}
func (suite *KopiaSimpleRepoIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvVars(tester.AWSStorageCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory(
testTenant,

View File

@ -437,22 +437,17 @@ type BackupOpIntegrationSuite struct {
}
func TestBackupOpIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoOperationTests,
tester.CorsoOperationBackupTests,
); err != nil {
t.Skip(err)
}
tester.CorsoOperationBackupTests)
suite.Run(t, new(BackupOpIntegrationSuite))
}
func (suite *BackupOpIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
suite.user = tester.M365UserID(suite.T())
suite.site = tester.M365SiteID(suite.T())

View File

@ -133,12 +133,10 @@ type RestoreOpIntegrationSuite struct {
}
func TestRestoreOpIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoOperationTests,
); err != nil {
t.Skip(err)
}
tester.CorsoOperationTests)
suite.Run(t, new(RestoreOpIntegrationSuite))
}
@ -147,8 +145,7 @@ func (suite *RestoreOpIntegrationSuite) SetupSuite() {
ctx, flush := tester.NewContext()
defer flush()
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs)
t := suite.T()

View File

@ -18,12 +18,7 @@ type StreamStoreIntegrationSuite struct {
}
func TestStreamStoreIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.CorsoCITests,
); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoCITests)
suite.Run(t, new(StreamStoreIntegrationSuite))
}

View File

@ -1,44 +0,0 @@
package tester
import (
"errors"
"os"
"golang.org/x/exp/maps"
)
// GetRequiredEnvVars retrieves the provided env vars from the os.
// Retrieved values are populated into the resulting map.
// If any of the env values are zero length, returns an error.
func GetRequiredEnvVars(evs ...string) (map[string]string, error) {
vals := map[string]string{}
for _, ev := range evs {
ge := os.Getenv(ev)
if len(ge) == 0 {
return nil, errors.New(ev + " env var required for test suite")
}
vals[ev] = ge
}
return vals, nil
}
// GetRequiredEnvSls retrieves the provided env vars from the os.
// Retrieved values are populated into the resulting map.
// If any of the env values are zero length, returns an error.
func GetRequiredEnvSls(evs ...[]string) (map[string]string, error) {
vals := map[string]string{}
for _, ev := range evs {
r, err := GetRequiredEnvVars(ev...)
if err != nil {
return nil, err
}
maps.Copy(vals, r)
}
return vals, nil
}

View File

@ -1,47 +0,0 @@
package tester
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type EnvvarsTestSuite struct {
suite.Suite
}
func TestEnvvarsSuite(t *testing.T) {
suite.Run(t, new(EnvvarsTestSuite))
}
func (suite *EnvvarsTestSuite) TestRunOnAny() {
envVariable := "TEST_ENVVARS_SUITE"
os.Setenv(envVariable, "1")
table := []struct {
name string
param string
function assert.ErrorAssertionFunc
}{
{
name: "Valid Environment",
param: envVariable,
function: assert.NoError,
},
{
name: "Invalid Environment",
param: "TEST_ENVVARS_SUITE_INVALID",
function: assert.Error,
},
}
for _, test := range table {
suite.T().Run(test.name, func(t *testing.T) {
result := RunOnAny(test.param)
test.function(suite.T(), result)
})
}
os.Unsetenv(envVariable)
}

View File

@ -1,11 +1,13 @@
package tester
import (
"fmt"
"os"
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
)
const (
@ -40,19 +42,17 @@ const CorsoGraphConnectorTestSupportFile = "CORSO_TEST_SUPPORT_FILE"
// an error if all of them are zero valued. Implication being:
// if any of those env vars are truthy, you should run the
// subsequent tests.
func RunOnAny(tests ...string) error {
func RunOnAny(t *testing.T, tests ...string) {
var l int
for _, test := range tests {
l += len(os.Getenv(test))
}
if l == 0 {
return fmt.Errorf(
"%s env vars are not flagged for testing",
t.Skipf(
"one or more env vars mus be flagged to run this test: %v",
strings.Join(tests, ", "))
}
return nil
}
// LogTimeOfTest logs the test name and the time that it was run.
@ -69,3 +69,33 @@ func LogTimeOfTest(t *testing.T) string {
return now
}
// MustGetEnvVars retrieves the provided env vars from the os.
// Retrieved values are populated into the resulting map.
// If any of the env values are zero length, the test errors.
func MustGetEnvVars(t *testing.T, evs ...string) map[string]string {
vals := map[string]string{}
for _, ev := range evs {
ge := os.Getenv(ev)
require.NotEmpty(t, ev, ev+" env var required for test suite")
vals[ev] = ge
}
return vals
}
// MustGetEnvSls retrieves the provided env vars from the os.
// Retrieved values are populated into the resulting map.
// If any of the env values are zero length, the test errors.
func MustGetEnvSets(t *testing.T, evs ...[]string) map[string]string {
vals := map[string]string{}
for _, ev := range evs {
r := MustGetEnvVars(t, ev...)
maps.Copy(vals, r)
}
return vals
}

View File

@ -48,24 +48,23 @@ func singleUserSet(t *testing.T) []string {
var loadCtx context.Context
func TestMain(m *testing.M) {
ctx, logFlush := tester.NewContext()
loadCtx = ctx
flush := func() {
logFlush()
if len(os.Getenv(tester.CorsoLoadTests)) == 0 {
return
}
if err := tester.RunOnAny(tester.CorsoLoadTests); err == nil {
if err := D.InitCollector(); err != nil {
fmt.Println("initializing load tests:", err)
os.Exit(1)
}
ctx, logFlush := tester.NewContext()
loadCtx = ctx
ctx, spanFlush := D.Start(ctx, "Load_Testing_Main")
loadCtx = ctx
flush = func() {
spanFlush()
logFlush()
}
if err := D.InitCollector(); err != nil {
fmt.Println("initializing load tests:", err)
os.Exit(1)
}
ctx, spanFlush := D.Start(ctx, "Load_Testing_Main")
loadCtx = ctx
flush := func() {
spanFlush()
logFlush()
}
exitVal := m.Run()
@ -80,13 +79,12 @@ func TestMain(m *testing.M) {
// ------------------------------------------------------------------------------------------------
func initM365Repo(t *testing.T) (
context.Context, repository.Repository, account.Account, storage.Storage,
context.Context,
repository.Repository,
account.Account,
storage.Storage,
) {
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs,
)
require.NoError(t, err)
tester.MustGetEnvSets(t, tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
ctx, flush := tester.WithContext(loadCtx)
defer flush()
@ -378,10 +376,7 @@ type RepositoryLoadTestExchangeSuite struct {
}
func TestRepositoryLoadTestExchangeSuite(t *testing.T) {
if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryLoadTestExchangeSuite))
}
@ -428,10 +423,7 @@ type RepositoryIndividualLoadTestExchangeSuite struct {
}
func TestRepositoryIndividualLoadTestExchangeSuite(t *testing.T) {
if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryIndividualLoadTestExchangeSuite))
}
@ -481,10 +473,7 @@ type RepositoryLoadTestOneDriveSuite struct {
}
func TestRepositoryLoadTestOneDriveSuite(t *testing.T) {
if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryLoadTestOneDriveSuite))
}
@ -528,10 +517,7 @@ type RepositoryIndividualLoadTestOneDriveSuite struct {
}
func TestRepositoryIndividualLoadTestOneDriveSuite(t *testing.T) {
if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryIndividualLoadTestOneDriveSuite))
}
@ -579,10 +565,7 @@ type RepositoryLoadTestSharePointSuite struct {
}
func TestRepositoryLoadTestSharePointSuite(t *testing.T) {
if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryLoadTestSharePointSuite))
}
@ -626,10 +609,7 @@ type RepositoryIndividualLoadTestSharePointSuite struct {
}
func TestRepositoryIndividualLoadTestSharePointSuite(t *testing.T) {
if err := tester.RunOnAny(tester.CorsoLoadTests); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoLoadTests)
suite.Run(t, new(RepositoryIndividualLoadTestOneDriveSuite))
}

View File

@ -96,22 +96,17 @@ type RepositoryIntegrationSuite struct {
}
func TestRepositoryIntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoRepositoryTests,
); err != nil {
t.Skip(err)
}
tester.CorsoRepositoryTests)
suite.Run(t, new(RepositoryIntegrationSuite))
}
// ensure all required env values are populated
func (suite *RepositoryIntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
}
func (suite *RepositoryIntegrationSuite) TestInitialize() {

View File

@ -16,22 +16,17 @@ type RepositoryModelSuite struct {
}
func TestRepositoryModelSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.RunOnAny(
t,
tester.CorsoCITests,
tester.CorsoRepositoryTests,
); err != nil {
t.Skip(err)
}
tester.CorsoRepositoryTests)
suite.Run(t, new(RepositoryModelSuite))
}
// ensure all required env values are populated
func (suite *RepositoryModelSuite) SetupSuite() {
_, err := tester.GetRequiredEnvSls(
tester.AWSStorageCredEnvs,
tester.M365AcctCredEnvs)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs, tester.M365AcctCredEnvs)
}
func (suite *RepositoryModelSuite) TestWriteGetModel() {

View File

@ -15,19 +15,12 @@ type M365IntegrationSuite struct {
}
func TestM365IntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.CorsoCITests,
); err != nil {
t.Skip(err)
}
tester.RunOnAny(t, tester.CorsoCITests)
suite.Run(t, new(M365IntegrationSuite))
}
func (suite *M365IntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvSls(
tester.M365AcctCredEnvs)
require.NoError(suite.T(), err)
tester.MustGetEnvSets(suite.T(), tester.M365AcctCredEnvs)
}
func (suite *M365IntegrationSuite) TestUsers() {