Show backup size for list commands (#1648)
## Description Add size and stored size to cli output for `backup list` ## Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [ ] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * fixes https://github.com/alcionai/corso/issues/1622 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
3eae0f969d
commit
d11183658a
@ -89,23 +89,27 @@ func PrintAll(ctx context.Context, bs []*Backup) {
|
||||
}
|
||||
|
||||
type Printable struct {
|
||||
ID model.StableID `json:"id"`
|
||||
ErrorCount int `json:"errorCount"`
|
||||
StartedAt time.Time `json:"started at"`
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Selectors selectors.Printable `json:"selectors"`
|
||||
ID model.StableID `json:"id"`
|
||||
ErrorCount int `json:"errorCount"`
|
||||
StartedAt time.Time `json:"started at"`
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Selectors selectors.Printable `json:"selectors"`
|
||||
BytesRead int64 `json:"bytesRead"`
|
||||
BytesUploaded int64 `json:"bytesUploaded"`
|
||||
}
|
||||
|
||||
// MinimumPrintable reduces the Backup to its minimally printable details.
|
||||
func (b Backup) MinimumPrintable() any {
|
||||
return Printable{
|
||||
ID: b.ID,
|
||||
ErrorCount: support.GetNumberOfErrors(b.ReadErrors) + support.GetNumberOfErrors(b.WriteErrors),
|
||||
StartedAt: b.StartedAt,
|
||||
Status: b.Status,
|
||||
Version: "0",
|
||||
Selectors: b.Selectors.ToPrintable(),
|
||||
ID: b.ID,
|
||||
ErrorCount: support.GetNumberOfErrors(b.ReadErrors) + support.GetNumberOfErrors(b.WriteErrors),
|
||||
StartedAt: b.StartedAt,
|
||||
Status: b.Status,
|
||||
Version: "0",
|
||||
Selectors: b.Selectors.ToPrintable(),
|
||||
BytesRead: b.BytesRead,
|
||||
BytesUploaded: b.BytesUploaded,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -45,8 +45,10 @@ func stubBackup(t time.Time) backup.Backup {
|
||||
WriteErrors: errors.New("1"),
|
||||
},
|
||||
ReadWrites: stats.ReadWrites{
|
||||
ItemsRead: 1,
|
||||
ItemsWritten: 1,
|
||||
BytesRead: 301,
|
||||
BytesUploaded: 301,
|
||||
ItemsRead: 1,
|
||||
ItemsWritten: 1,
|
||||
},
|
||||
StartAndEndTime: stats.StartAndEndTime{
|
||||
StartedAt: t,
|
||||
@ -98,4 +100,7 @@ func (suite *BackupSuite) TestBackup_MinimumPrintable() {
|
||||
bselp := b.Selectors.ToPrintable()
|
||||
assert.Equal(t, bselp, result.Selectors, "selectors")
|
||||
assert.Equal(t, bselp.Resources(), result.Selectors.Resources(), "selector resources")
|
||||
|
||||
assert.Equal(t, b.BytesRead, result.BytesRead, "size")
|
||||
assert.Equal(t, b.BytesUploaded, result.BytesUploaded, "stored size")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user