Skip to content

Commit

Permalink
Reset FakeMedusaClient state between individual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvoncek committed Oct 29, 2024
1 parent c11b491 commit ec79354
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions controllers/medusa/medusabackupjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ type fakeMedusaClient struct {
}

func newFakeMedusaClient(dcName string) *fakeMedusaClient {
// the fake Medusa client keeps a bit of state in order to simulate different backup statuses
// more precisely, for some backups it will return not a success for some nodes
// we need to reset this state between tests
// doing it here is great since we make a new fake client for each test anyway
alreadyReportedFailingBackup = false
alreadyReportedMissingBackup = false
return &fakeMedusaClient{RequestedBackups: make([]string, 0), DcName: dcName}
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/medusa/medusatask_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ func testMedusaTasks(t *testing.T, ctx context.Context, f *framework.Framework,
backup4Created := createAndVerifyMedusaBackup(dc2Key, dc2, f, ctx, require, t, namespace, backup4)
require.True(backup4Created, "failed to create backup4")
backup5Created := createAndVerifyMedusaBackup(dc2Key, dc2, f, ctx, require, t, namespace, backup5)
require.False(backup5Created, "failed to create backup4")
require.False(backup5Created, "failed to create backup5")
backup6Created := createAndVerifyMedusaBackup(dc2Key, dc2, f, ctx, require, t, namespace, backup6)
require.False(backup6Created, "failed to create backup4")
require.False(backup6Created, "failed to create backup6")

// Ensure that 6 backups jobs, but only 4 backups were created (two jobs did not succeed on some pods)
checkBackupsAndJobs(require, ctx, 6, 4, namespace, f, []string{})
Expand Down

0 comments on commit ec79354

Please sign in to comment.