From 8f236019ad8d4e7bf3044781b248fea6ec426542 Mon Sep 17 00:00:00 2001 From: ryanfkeepers Date: Wed, 23 Aug 2023 16:24:02 -0600 Subject: [PATCH] fix up e2e tests fixing failures discovered from manual runs --- src/cli/backup/exchange_e2e_test.go | 83 +++++++++++++++++++---------- src/cli/backup/helpers_test.go | 2 +- 2 files changed, 56 insertions(+), 29 deletions(-) diff --git a/src/cli/backup/exchange_e2e_test.go b/src/cli/backup/exchange_e2e_test.go index 0cab8058f..99086066f 100644 --- a/src/cli/backup/exchange_e2e_test.go +++ b/src/cli/backup/exchange_e2e_test.go @@ -32,6 +32,61 @@ var ( events = path.EventsCategory ) +// --------------------------------------------------------------------------- +// tests that depend on no backups existing +// --------------------------------------------------------------------------- + +type NoBackupExchangeE2ESuite struct { + tester.Suite + dpnd dependencies + its intgTesterSetup +} + +func TestNoBackupExchangeE2ESuite(t *testing.T) { + suite.Run(t, &BackupExchangeE2ESuite{Suite: tester.NewE2ESuite( + t, + [][]string{storeTD.AWSStorageCredEnvs, tconfig.M365AcctCredEnvs}, + )}) +} + +func (suite *NoBackupExchangeE2ESuite) SetupSuite() { + t := suite.T() + + ctx, flush := tester.NewContext(t) + defer flush() + + suite.its = newIntegrationTesterSetup(t) + suite.dpnd = prepM365Test(t, ctx) +} + +func (suite *NoBackupExchangeE2ESuite) TestExchangeBackupListCmd_noBackups() { + t := suite.T() + ctx, flush := tester.NewContext(t) + ctx = config.SetViper(ctx, suite.dpnd.vpr) + + defer flush() + + suite.dpnd.recorder.Reset() + + cmd := cliTD.StubRootCmd( + "backup", "list", "exchange", + "--config-file", suite.dpnd.configFilePath) + cli.BuildCommandTree(cmd) + + cmd.SetErr(&suite.dpnd.recorder) + + ctx = print.SetRootCmd(ctx, cmd) + + // run the command + err := cmd.ExecuteContext(ctx) + require.NoError(t, err, clues.ToCore(err)) + + result := suite.dpnd.recorder.String() + + // as an offhand check: the result should contain the m365 user id + assert.True(t, strings.HasSuffix(result, "No backups available\n")) +} + // --------------------------------------------------------------------------- // tests with no prior backup // --------------------------------------------------------------------------- @@ -178,34 +233,6 @@ func runExchangeBackupUserNotFoundTest(suite *BackupExchangeE2ESuite, category p t.Log("backup results", result) } -func (suite *BackupExchangeE2ESuite) TestExchangeBackupListCmd_empty() { - t := suite.T() - ctx, flush := tester.NewContext(t) - ctx = config.SetViper(ctx, suite.dpnd.vpr) - - defer flush() - - suite.dpnd.recorder.Reset() - - cmd := cliTD.StubRootCmd( - "backup", "list", "exchange", - "--config-file", suite.dpnd.configFilePath) - cli.BuildCommandTree(cmd) - - cmd.SetErr(&suite.dpnd.recorder) - - ctx = print.SetRootCmd(ctx, cmd) - - // run the command - err := cmd.ExecuteContext(ctx) - require.NoError(t, err, clues.ToCore(err)) - - result := suite.dpnd.recorder.String() - - // as an offhand check: the result should contain the m365 user id - assert.True(t, strings.HasSuffix(result, "No backups available\n")) -} - func (suite *BackupExchangeE2ESuite) TestBackupCreateExchange_badAzureClientIDFlag() { t := suite.T() ctx, flush := tester.NewContext(t) diff --git a/src/cli/backup/helpers_test.go b/src/cli/backup/helpers_test.go index 43e296b3b..e5803a0e7 100644 --- a/src/cli/backup/helpers_test.go +++ b/src/cli/backup/helpers_test.go @@ -96,7 +96,7 @@ func newIntegrationTesterSetup(t *testing.T) intgTesterSetup { sids.DriveID = ptr.Val(siteDrive.GetId()) - siteDriveRootFolder, err := its.ac.Drives().GetRootFolder(ctx, sids.ID) + siteDriveRootFolder, err := its.ac.Drives().GetRootFolder(ctx, sids.DriveID) require.NoError(t, err, clues.ToCore(err)) sids.DriveRootFolderID = ptr.Val(siteDriveRootFolder.GetId())