Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
remove selector printable, list discreteOwner
Browse files Browse the repository at this point in the history
The selectors printable code wasn't being used in any
valid way, so that's out.  Backup List printing now refers
to the DiscreteOwner in the embedded selector as the
ResourceOwner reference.  Renamed the "Selectors"
column in the List print table to "Resource Owner" to
better match what should be contained in that field.
  • Loading branch information
ryanfkeepers committed Jan 5, 2023
1 parent 2b45cfa commit d75ecbc
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 328 deletions.
6 changes: 0 additions & 6 deletions src/cli/utils/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,42 +325,36 @@ func (suite *ExchangeUtilsSuite) TestAddExchangeInclude() {
}{
{
name: "no inputs",
resources: empty,
folders: empty,
items: empty,
expectIncludeLen: 0,
},
{
name: "single inputs",
resources: single,
folders: single,
items: single,
expectIncludeLen: 1,
},
{
name: "multi inputs",
resources: multi,
folders: multi,
items: multi,
expectIncludeLen: 1,
},
{
name: "folder contains",
resources: empty,
folders: containsOnly,
items: empty,
expectIncludeLen: 1,
},
{
name: "folder prefixes",
resources: empty,
folders: prefixOnly,
items: empty,
expectIncludeLen: 1,
},
{
name: "folder prefixes and contains",
resources: empty,
folders: containsAndPrefix,
items: empty,
expectIncludeLen: 2,
Expand Down
6 changes: 4 additions & 2 deletions src/internal/connector/exchange/data_collections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,16 @@ func (suite *DataCollectionsIntegrationSuite) TestEventsSerializationRegression(
expected: DefaultCalendar,
scope: selectors.NewExchangeBackup(users).EventCalendars(
[]string{DefaultCalendar},
selectors.PrefixMatch())[0],
selectors.PrefixMatch(),
)[0],
},
{
name: "Birthday Calendar",
expected: "Birthdays",
scope: selectors.NewExchangeBackup(users).EventCalendars(
[]string{"Birthdays"},
selectors.PrefixMatch())[0],
selectors.PrefixMatch(),
)[0],
},
}

Expand Down
26 changes: 12 additions & 14 deletions src/pkg/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type Backup struct {
// Status of the operation
Status string `json:"status"`

// Selectors used in this operation
Selectors selectors.Selector `json:"selectors"`
// Selector used in this operation
Selector selectors.Selector `json:"selectors"`

// stats are embedded so that the values appear as top-level properties
stats.Errs
Expand Down Expand Up @@ -58,7 +58,7 @@ func New(
SnapshotID: snapshotID,
DetailsID: detailsID,
Status: status,
Selectors: selector,
Selector: selector,
ReadWrites: rw,
StartAndEndTime: se,
}
Expand Down Expand Up @@ -89,14 +89,13 @@ 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"`
BytesRead int64 `json:"bytesRead"`
BytesUploaded int64 `json:"bytesUploaded"`
ID model.StableID `json:"id"`
ErrorCount int `json:"errorCount"`
StartedAt time.Time `json:"started at"`
Status string `json:"status"`
Version string `json:"version"`
BytesRead int64 `json:"bytesRead"`
BytesUploaded int64 `json:"bytesUploaded"`
}

// MinimumPrintable reduces the Backup to its minimally printable details.
Expand All @@ -107,7 +106,6 @@ func (b Backup) MinimumPrintable() any {
StartedAt: b.StartedAt,
Status: b.Status,
Version: "0",
Selectors: b.Selectors.ToPrintable(),
BytesRead: b.BytesRead,
BytesUploaded: b.BytesUploaded,
}
Expand All @@ -120,7 +118,7 @@ func (b Backup) Headers() []string {
"Started At",
"ID",
"Status",
"Selectors",
"Resource Owner",
}
}

Expand All @@ -134,6 +132,6 @@ func (b Backup) Values() []string {
common.FormatTabularDisplayTime(b.StartedAt),
string(b.ID),
status,
b.Selectors.ToPrintable().Resources(),
b.Selector.DiscreteOwner,
}
}
13 changes: 4 additions & 9 deletions src/pkg/backup/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestBackupSuite(t *testing.T) {
}

func stubBackup(t time.Time) backup.Backup {
sel := selectors.NewExchangeBackup(selectors.Any())
sel := selectors.NewExchangeBackup([]string{"test"})
sel.Include(sel.AllData())

return backup.Backup{
Expand All @@ -39,7 +39,7 @@ func stubBackup(t time.Time) backup.Backup {
SnapshotID: "snapshot",
DetailsID: "details",
Status: "status",
Selectors: sel.Selector,
Selector: sel.Selector,
Errs: stats.Errs{
ReadErrors: errors.New("1"),
WriteErrors: errors.New("1"),
Expand All @@ -66,7 +66,7 @@ func (suite *BackupSuite) TestBackup_HeadersValues() {
"Started At",
"ID",
"Status",
"Selectors",
"Resource Owner",
}
hs := b.Headers()
assert.Equal(t, expectHs, hs)
Expand All @@ -76,7 +76,7 @@ func (suite *BackupSuite) TestBackup_HeadersValues() {
nowFmt,
"id",
"status (2 errors)",
selectors.All,
"test",
}

vs := b.Values()
Expand All @@ -96,11 +96,6 @@ func (suite *BackupSuite) TestBackup_MinimumPrintable() {
assert.Equal(t, 2, result.ErrorCount, "error count")
assert.Equal(t, now, result.StartedAt, "started at")
assert.Equal(t, b.Status, result.Status, "status")

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")
}
2 changes: 1 addition & 1 deletion src/pkg/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (r repository) BackupDetails(ctx context.Context, backupID string) (*detail
deets, err := streamstore.New(
r.dataLayer,
r.Account.ID(),
b.Selectors.PathService()).ReadBackupDetails(ctx, dID)
b.Selector.PathService()).ReadBackupDetails(ctx, dID)
if err != nil {
return nil, nil, err
}
Expand Down
6 changes: 0 additions & 6 deletions src/pkg/selectors/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type (

var (
_ Reducer = &ExchangeRestore{}
_ printabler = &ExchangeRestore{}
_ pathCategorier = &ExchangeRestore{}
)

Expand Down Expand Up @@ -110,11 +109,6 @@ func (sr ExchangeRestore) SplitByResourceOwner(users []string) []ExchangeRestore
return ss
}

// Printable creates the minimized display of a selector, formatted for human readability.
func (s exchange) Printable() Printable {
return toPrintable[ExchangeScope](s.Selector)
}

// PathCategories produces the aggregation of discrete users described by each type of scope.
func (s exchange) PathCategories() selectorPathCategories {
return selectorPathCategories{
Expand Down
4 changes: 0 additions & 4 deletions src/pkg/selectors/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ func stubSelector(resourceOwners []string) mockSel {
}
}

func (s mockSel) Printable() Printable {
return toPrintable[mockScope](s.Selector)
}

// ---------------------------------------------------------------------------
// helper funcs
// ---------------------------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions src/pkg/selectors/onedrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ type (

var (
_ Reducer = &OneDriveRestore{}
_ printabler = &OneDriveRestore{}
_ pathCategorier = &OneDriveRestore{}
)

Expand Down Expand Up @@ -109,11 +108,6 @@ func (s OneDriveRestore) SplitByResourceOwner(users []string) []OneDriveRestore
return ss
}

// Printable creates the minimized display of a selector, formatted for human readability.
func (s oneDrive) Printable() Printable {
return toPrintable[OneDriveScope](s.Selector)
}

// PathCategories produces the aggregation of discrete users described by each type of scope.
func (s oneDrive) PathCategories() selectorPathCategories {
return selectorPathCategories{
Expand Down
27 changes: 0 additions & 27 deletions src/pkg/selectors/scopes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,33 +393,6 @@ func (suite *SelectorScopesSuite) TestMatchesPathValues() {
}
}

func (suite *SelectorScopesSuite) TestAddToSet() {
t := suite.T()
set := []string{}

set = addToSet(set, []string{})
assert.Len(t, set, 0)

set = addToSet(set, []string{"a"})
assert.Len(t, set, 1)
assert.Equal(t, set[0], "a")

set = addToSet(set, []string{"a"})
assert.Len(t, set, 1)

set = addToSet(set, []string{"a", "b"})
assert.Len(t, set, 2)
assert.Equal(t, set[0], "a")
assert.Equal(t, set[1], "b")

set = addToSet(set, []string{"c", "d"})
assert.Len(t, set, 4)
assert.Equal(t, set[0], "a")
assert.Equal(t, set[1], "b")
assert.Equal(t, set[2], "c")
assert.Equal(t, set[3], "d")
}

func (suite *SelectorScopesSuite) TestClean() {
table := []struct {
name string
Expand Down
Loading

0 comments on commit d75ecbc

Please sign in to comment.