Don't go for snapshot deletion in case of empty backup (#3250)
<!-- PR description--> Fix: https://github.com/alcionai/corso/issues/3050 In case of a blank backup, don't go for snapshot deletion. #### Does this PR need a docs update or release note? - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🐛 Bugfix #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * https://github.com/alcionai/corso/issues/3050 #### Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [ ] ⚡ Unit test
This commit is contained in:
parent
57dfa3d38a
commit
ca9425a329
@ -549,10 +549,6 @@ func deleteBackup(
|
||||
return errWrapper(err)
|
||||
}
|
||||
|
||||
if err := kw.DeleteSnapshot(ctx, b.SnapshotID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(b.SnapshotID) > 0 {
|
||||
if err := kw.DeleteSnapshot(ctx, b.SnapshotID); err != nil {
|
||||
return err
|
||||
|
||||
@ -112,6 +112,10 @@ func (suite *RepositoryBackupsUnitSuite) TestDeleteBackup() {
|
||||
},
|
||||
}
|
||||
|
||||
bupNoSnapshot := &backup.Backup{
|
||||
BaseModel: model.BaseModel{},
|
||||
}
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
sw mock.BackupWrapper
|
||||
@ -172,6 +176,19 @@ func (suite *RepositoryBackupsUnitSuite) TestDeleteBackup() {
|
||||
},
|
||||
expectID: bup.ID,
|
||||
},
|
||||
{
|
||||
name: "no snapshot present",
|
||||
sw: mock.BackupWrapper{
|
||||
Backup: bupNoSnapshot,
|
||||
GetErr: nil,
|
||||
DeleteErr: nil,
|
||||
},
|
||||
kw: mockSSDeleter{assert.AnError},
|
||||
expectErr: func(t *testing.T, result error) {
|
||||
assert.NoError(t, result, clues.ToCore(result))
|
||||
},
|
||||
expectID: bupNoSnapshot.ID,
|
||||
},
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.Run(test.name, func() {
|
||||
@ -180,7 +197,7 @@ func (suite *RepositoryBackupsUnitSuite) TestDeleteBackup() {
|
||||
|
||||
t := suite.T()
|
||||
|
||||
err := deleteBackup(ctx, string(bup.ID), test.kw, test.sw)
|
||||
err := deleteBackup(ctx, string(test.sw.Backup.ID), test.kw, test.sw)
|
||||
test.expectErr(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ func (bw BackupWrapper) GetBackup(
|
||||
ctx context.Context,
|
||||
backupID model.StableID,
|
||||
) (*backup.Backup, error) {
|
||||
bw.Backup.SnapshotID = bw.Backup.ID.String()
|
||||
|
||||
return bw.Backup, bw.GetErr
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user