Skip kopia upload when no collections given (#846)

## Description

<!-- Insert PR description-->
Currently does not throw an error. Open to other suggestions on return values.

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [x] 🐛 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. -->
* closes #844 
* #1000 

## Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2022-10-03 10:49:20 -07:00 committed by GitHub
parent 7fa86824e9
commit 56287c42fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -390,6 +390,10 @@ func (w Wrapper) BackupCollections(
defer trace.StartRegion(ctx, "kopia:backupCollections").End()
if len(collections) == 0 {
return &BackupStats{}, &details.Details{}, nil
}
progress := &corsoProgress{
pending: map[string]*itemDetails{},
deets: &details.Details{},

View File

@ -780,6 +780,34 @@ type backedupFile struct {
data []byte
}
func (suite *KopiaIntegrationSuite) TestBackupCollectionsHandlesNoCollections() {
table := []struct {
name string
collections []data.Collection
}{
{
name: "NilCollections",
collections: nil,
},
{
name: "EmptyCollections",
collections: []data.Collection{},
},
}
for _, test := range table {
suite.T().Run(test.name, func(t *testing.T) {
ctx := context.Background()
s, d, err := suite.w.BackupCollections(ctx, test.collections)
require.NoError(t, err)
assert.Equal(t, BackupStats{}, *s)
assert.Empty(t, d.Entries)
})
}
}
type KopiaSimpleRepoIntegrationSuite struct {
suite.Suite
w *Wrapper