Remove old code to count number of resource owners backed up (#2414)

## Description

Remove unused code that counted the number of resource owners that participated in the backup. This is no longer required as we've restricted each backup to act on a single resource owner

## Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No 

## Type of change

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

## Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-02-07 11:32:50 -08:00 committed by GitHub
parent 231038de90
commit 27c1e5c511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 133 deletions

View File

@ -86,38 +86,3 @@ type StreamSize interface {
type StreamModTime interface { type StreamModTime interface {
ModTime() time.Time ModTime() time.Time
} }
// ------------------------------------------------------------------------------------------------
// functionality
// ------------------------------------------------------------------------------------------------
// ResourceOwnerSet extracts the set of unique resource owners from the
// slice of Collections.
func ResourceOwnerSet(cs []Collection) []string {
rs := map[string]struct{}{}
for _, c := range cs {
fp := c.FullPath()
if fp == nil {
// Deleted collections have their full path set to nil but the previous
// path will be populated.
fp = c.PreviousPath()
}
if fp == nil {
// This should not happen, but keep us from hitting a nil pointer
// exception if it does somehow occur. Statistics will be off though.
continue
}
rs[fp.ResourceOwner()] = struct{}{}
}
rss := make([]string, 0, len(rs))
for k := range rs {
rss = append(rss, k)
}
return rss
}

View File

@ -1,98 +0,0 @@
package data
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/alcionai/corso/src/pkg/path"
)
type mockColl struct {
p path.Path
prevP path.Path
}
func (mc mockColl) Items() <-chan Stream {
return nil
}
func (mc mockColl) FullPath() path.Path {
return mc.p
}
func (mc mockColl) PreviousPath() path.Path {
return mc.prevP
}
func (mc mockColl) State() CollectionState {
return NewState
}
func (mc mockColl) DoNotMergeItems() bool {
return false
}
type CollectionSuite struct {
suite.Suite
}
// ------------------------------------------------------------------------------------------------
// tests
// ------------------------------------------------------------------------------------------------
func TestCollectionSuite(t *testing.T) {
suite.Run(t, new(CollectionSuite))
}
func (suite *CollectionSuite) TestResourceOwnerSet() {
t := suite.T()
toColl := func(t *testing.T, resource string) Collection {
p, err := path.Builder{}.
Append("foo").
ToDataLayerExchangePathForCategory("tid", resource, path.EventsCategory, false)
require.NoError(t, err)
return mockColl{p, nil}
}
table := []struct {
name string
input []Collection
expect []string
}{
{
name: "empty",
input: []Collection{},
expect: []string{},
},
{
name: "nil",
input: nil,
expect: []string{},
},
{
name: "single resource",
input: []Collection{toColl(t, "fnords")},
expect: []string{"fnords"},
},
{
name: "multiple resource",
input: []Collection{toColl(t, "fnords"), toColl(t, "smarfs")},
expect: []string{"fnords", "smarfs"},
},
{
name: "duplciate resources",
input: []Collection{toColl(t, "fnords"), toColl(t, "smarfs"), toColl(t, "fnords")},
expect: []string{"fnords", "smarfs"},
},
}
for _, test := range table {
suite.T().Run(test.name, func(t *testing.T) {
rs := ResourceOwnerSet(test.input)
assert.ElementsMatch(t, test.expect, rs)
})
}
}