diff --git a/src/internal/kopia/wrapper.go b/src/internal/kopia/wrapper.go index dd2aae9e9..5801917aa 100644 --- a/src/internal/kopia/wrapper.go +++ b/src/internal/kopia/wrapper.go @@ -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{}, diff --git a/src/internal/kopia/wrapper_test.go b/src/internal/kopia/wrapper_test.go index 867672f73..7c960deb3 100644 --- a/src/internal/kopia/wrapper_test.go +++ b/src/internal/kopia/wrapper_test.go @@ -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