Compare commits

...

2 Commits

Author SHA1 Message Date
ryanfkeepers
dceb5f9506 quick test for tags 2023-04-11 14:59:55 -06:00
ryanfkeepers
30b86f664e tag a union of reason and fallback reasons 2023-04-11 14:54:29 -06:00
2 changed files with 42 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/alcionai/clues"
"github.com/google/uuid"
"golang.org/x/exp/slices"
"github.com/alcionai/corso/src/internal/common"
"github.com/alcionai/corso/src/internal/common/crash"
@ -269,7 +270,7 @@ func (op *BackupOperation) do(
ctx,
op.kopia,
op.account.ID(),
reasons,
reasons, fallbackReasons,
mans,
cs,
excludes,
@ -405,7 +406,7 @@ func consumeBackupCollections(
ctx context.Context,
bc inject.BackupConsumer,
tenantID string,
reasons []kopia.Reason,
reasons, fallbackReasons []kopia.Reason,
mans []*kopia.ManifestEntry,
cs []data.BackupCollection,
excludes map[string]map[string]struct{},
@ -425,7 +426,8 @@ func consumeBackupCollections(
kopia.TagBackupCategory: "",
}
for _, reason := range reasons {
reunion := append(slices.Clone(reasons), fallbackReasons...)
for _, reason := range reunion {
for _, k := range reason.TagKeys() {
tags[k] = ""
}

View File

@ -561,6 +561,15 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_ConsumeBackupDataCollections
ctx, flush := tester.NewContext()
defer flush()
expectTags := map[string]string{
"backup-id": "",
"bob": "",
"bobby": "",
"exchangecontacts": "",
"exchangeemail": "",
"is-canon-backup": "",
}
mbu := &mockBackupConsumer{
checkFunc: func(
bases []kopia.IncrementalBase,
@ -568,16 +577,43 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_ConsumeBackupDataCollections
tags map[string]string,
buildTreeWithBase bool,
) {
assert.Equal(t, expectTags, tags)
assert.ElementsMatch(t, test.expected, bases)
},
}
reasons := []kopia.Reason{
{
ResourceOwner: "bob",
Service: path.ExchangeService,
Category: path.EmailCategory,
},
{
ResourceOwner: "bobby",
Service: path.ExchangeService,
Category: path.EmailCategory,
},
}
fallbackReasons := []kopia.Reason{
{
ResourceOwner: "bob",
Service: path.ExchangeService,
Category: path.EmailCategory,
},
{
ResourceOwner: "bob",
Service: path.ExchangeService,
Category: path.ContactsCategory,
},
}
//nolint:errcheck
consumeBackupCollections(
ctx,
mbu,
tenant,
nil,
reasons, fallbackReasons,
test.inputMan,
nil,
nil,