Return proper error when backups are empty for details command (#4968)
<!-- PR description--> --- #### Does this PR need a docs update or release note? - [x] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
1f97c96285
commit
35ac37313d
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased] (beta)
|
## [Unreleased] (beta)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- When running `backup details` on an empty backup returns a more helpful error message.
|
||||||
|
|
||||||
## [v0.18.0] (beta) - 2024-01-02
|
## [v0.18.0] (beta) - 2024-01-02
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@ -28,6 +28,8 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/store"
|
"github.com/alcionai/corso/src/pkg/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrEmptyBackup = clues.New("no items in backup")
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// adding commands to cobra
|
// adding commands to cobra
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -394,6 +396,10 @@ func genericDetailsCore(
|
|||||||
return nil, clues.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
return nil, clues.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(d.Entries) == 0 {
|
||||||
|
return nil, ErrEmptyBackup
|
||||||
|
}
|
||||||
|
|
||||||
if opts.SkipReduce {
|
if opts.SkipReduce {
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,10 +5,12 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/utils/testdata"
|
"github.com/alcionai/corso/src/cli/utils/testdata"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
dtd "github.com/alcionai/corso/src/pkg/backup/details/testdata"
|
dtd "github.com/alcionai/corso/src/pkg/backup/details/testdata"
|
||||||
"github.com/alcionai/corso/src/pkg/control"
|
"github.com/alcionai/corso/src/pkg/control"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
@ -66,3 +68,30 @@ func (suite *BackupUnitSuite) TestGenericDetailsCore() {
|
|||||||
assert.NoError(t, err, clues.ToCore(err))
|
assert.NoError(t, err, clues.ToCore(err))
|
||||||
assert.ElementsMatch(t, expected, output.Entries)
|
assert.ElementsMatch(t, expected, output.Entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *BackupUnitSuite) TestGenericDetailsCore_empty() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
ctx, flush := tester.NewContext(t)
|
||||||
|
defer flush()
|
||||||
|
|
||||||
|
bg := testdata.VersionedBackupGetter{
|
||||||
|
Details: &details.Details{
|
||||||
|
DetailsModel: details.DetailsModel{
|
||||||
|
Entries: []details.Entry{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
sel := selectors.NewExchangeBackup([]string{"user-id"})
|
||||||
|
sel.Include(sel.AllData())
|
||||||
|
|
||||||
|
_, err := genericDetailsCore(
|
||||||
|
ctx,
|
||||||
|
bg,
|
||||||
|
"backup-ID",
|
||||||
|
sel.Selector,
|
||||||
|
control.DefaultOptions())
|
||||||
|
require.Error(t, err, "has error")
|
||||||
|
assert.ErrorIs(t, err, ErrEmptyBackup, clues.ToCore(err))
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user