return path service and resource
Returns the path interface funcs for Service and Resource, this time as "primaryFoo" funcs, to indicate that these are the primary service and resource values. This functionality is mostly for quality of life.
This commit is contained in:
parent
3d15a0d649
commit
f5400f9e31
@ -724,8 +724,10 @@ func TestKopiaIntegrationSuite(t *testing.T) {
|
|||||||
func (suite *KopiaIntegrationSuite) SetupSuite() {
|
func (suite *KopiaIntegrationSuite) SetupSuite() {
|
||||||
tmp, err := path.Build(
|
tmp, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
testInboxDir)
|
testInboxDir)
|
||||||
@ -736,8 +738,10 @@ func (suite *KopiaIntegrationSuite) SetupSuite() {
|
|||||||
|
|
||||||
tmp, err = path.Build(
|
tmp, err = path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
testArchiveDir)
|
testArchiveDir)
|
||||||
@ -804,14 +808,14 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections() {
|
|||||||
reasons := []identity.Reasoner{
|
reasons := []identity.Reasoner{
|
||||||
NewReason(
|
NewReason(
|
||||||
testTenant,
|
testTenant,
|
||||||
suite.storePath1.ResourceOwner(),
|
suite.storePath1.PrimaryProtectedResource(),
|
||||||
suite.storePath1.Service(),
|
suite.storePath1.PrimaryService(),
|
||||||
suite.storePath1.Category(),
|
suite.storePath1.Category(),
|
||||||
),
|
),
|
||||||
NewReason(
|
NewReason(
|
||||||
testTenant,
|
testTenant,
|
||||||
suite.storePath2.ResourceOwner(),
|
suite.storePath2.PrimaryProtectedResource(),
|
||||||
suite.storePath2.Service(),
|
suite.storePath2.PrimaryService(),
|
||||||
suite.storePath2.Category(),
|
suite.storePath2.Category(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -1052,8 +1056,10 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections() {
|
|||||||
func (suite *KopiaIntegrationSuite) TestBackupCollections_NoDetailsForMeta() {
|
func (suite *KopiaIntegrationSuite) TestBackupCollections_NoDetailsForMeta() {
|
||||||
tmp, err := path.Build(
|
tmp, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.OneDriveService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.OneDriveService,
|
||||||
|
}},
|
||||||
path.FilesCategory,
|
path.FilesCategory,
|
||||||
false,
|
false,
|
||||||
testInboxDir)
|
testInboxDir)
|
||||||
@ -1079,8 +1085,8 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections_NoDetailsForMeta() {
|
|||||||
reasons := []identity.Reasoner{
|
reasons := []identity.Reasoner{
|
||||||
NewReason(
|
NewReason(
|
||||||
testTenant,
|
testTenant,
|
||||||
storePath.ResourceOwner(),
|
storePath.PrimaryProtectedResource(),
|
||||||
storePath.Service(),
|
storePath.PrimaryService(),
|
||||||
storePath.Category()),
|
storePath.Category()),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1507,8 +1513,10 @@ func TestKopiaSimpleRepoIntegrationSuite(t *testing.T) {
|
|||||||
func (suite *KopiaSimpleRepoIntegrationSuite) SetupSuite() {
|
func (suite *KopiaSimpleRepoIntegrationSuite) SetupSuite() {
|
||||||
tmp, err := path.Build(
|
tmp, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
testInboxDir)
|
testInboxDir)
|
||||||
@ -1518,8 +1526,10 @@ func (suite *KopiaSimpleRepoIntegrationSuite) SetupSuite() {
|
|||||||
|
|
||||||
tmp, err = path.Build(
|
tmp, err = path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
testArchiveDir)
|
testArchiveDir)
|
||||||
@ -1800,8 +1810,10 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestBackupExcludeItem() {
|
|||||||
func (suite *KopiaSimpleRepoIntegrationSuite) TestProduceRestoreCollections() {
|
func (suite *KopiaSimpleRepoIntegrationSuite) TestProduceRestoreCollections() {
|
||||||
doesntExist, err := path.Build(
|
doesntExist, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
true,
|
true,
|
||||||
"subdir", "foo")
|
"subdir", "foo")
|
||||||
@ -1934,8 +1946,10 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestProduceRestoreCollections() {
|
|||||||
func (suite *KopiaSimpleRepoIntegrationSuite) TestProduceRestoreCollections_PathChanges() {
|
func (suite *KopiaSimpleRepoIntegrationSuite) TestProduceRestoreCollections_PathChanges() {
|
||||||
rp1, err := path.Build(
|
rp1, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"corso_restore", "Inbox")
|
"corso_restore", "Inbox")
|
||||||
@ -1943,8 +1957,10 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestProduceRestoreCollections_Path
|
|||||||
|
|
||||||
rp2, err := path.Build(
|
rp2, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"corso_restore", "Archive")
|
"corso_restore", "Archive")
|
||||||
@ -2057,8 +2073,10 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestProduceRestoreCollections_Fetc
|
|||||||
|
|
||||||
rp1, err := path.Build(
|
rp1, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
ProtectedResource: testUser,
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"corso_restore", "Inbox")
|
"corso_restore", "Inbox")
|
||||||
|
|||||||
@ -538,8 +538,8 @@ func consumeBackupCollections(
|
|||||||
|
|
||||||
func matchesReason(reasons []identity.Reasoner, p path.Path) bool {
|
func matchesReason(reasons []identity.Reasoner, p path.Path) bool {
|
||||||
for _, reason := range reasons {
|
for _, reason := range reasons {
|
||||||
if p.ResourceOwner() == reason.ProtectedResource() &&
|
if p.PrimaryProtectedResource() == reason.ProtectedResource() &&
|
||||||
p.Service() == reason.Service() &&
|
p.PrimaryService() == reason.Service() &&
|
||||||
p.Category() == reason.Category() {
|
p.Category() == reason.Category() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -617,13 +617,13 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
|||||||
|
|
||||||
pathReason1 = kopia.NewReason(
|
pathReason1 = kopia.NewReason(
|
||||||
"",
|
"",
|
||||||
itemPath1.ResourceOwner(),
|
itemPath1.PrimaryProtectedResource(),
|
||||||
itemPath1.Service(),
|
itemPath1.PrimaryService(),
|
||||||
itemPath1.Category())
|
itemPath1.Category())
|
||||||
pathReason3 = kopia.NewReason(
|
pathReason3 = kopia.NewReason(
|
||||||
"",
|
"",
|
||||||
itemPath3.ResourceOwner(),
|
itemPath3.PrimaryProtectedResource(),
|
||||||
itemPath3.Service(),
|
itemPath3.PrimaryService(),
|
||||||
itemPath3.Category())
|
itemPath3.Category())
|
||||||
|
|
||||||
time1 = time.Now()
|
time1 = time.Now()
|
||||||
@ -1240,8 +1240,8 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsFolde
|
|||||||
|
|
||||||
pathReason1 = kopia.NewReason(
|
pathReason1 = kopia.NewReason(
|
||||||
"",
|
"",
|
||||||
itemPath1.ResourceOwner(),
|
itemPath1.PrimaryProtectedResource(),
|
||||||
itemPath1.Service(),
|
itemPath1.PrimaryService(),
|
||||||
itemPath1.Category())
|
itemPath1.Category())
|
||||||
|
|
||||||
backup1 = kopia.BackupEntry{
|
backup1 = kopia.BackupEntry{
|
||||||
|
|||||||
@ -78,47 +78,58 @@ var (
|
|||||||
// Resources that don't have the requested information should return an empty
|
// Resources that don't have the requested information should return an empty
|
||||||
// string.
|
// string.
|
||||||
type Path interface {
|
type Path interface {
|
||||||
String() string
|
// parts
|
||||||
|
|
||||||
|
Tenant() string
|
||||||
// ServiceResources produces all of the services and subservices, along with
|
// ServiceResources produces all of the services and subservices, along with
|
||||||
// the protected resource paired with the service, as contained in the path,
|
// the protected resource paired with the service, as contained in the path,
|
||||||
// in their order of appearance.
|
// in their order of appearance.
|
||||||
ServiceResources() []ServiceResource
|
ServiceResources() []ServiceResource
|
||||||
|
// PrimaryService is the first service in ServiceResources()
|
||||||
|
PrimaryService() ServiceType
|
||||||
|
// PrimaryProtectedResource is the first ProtectedResource in ServiceResources()
|
||||||
|
PrimaryProtectedResource() string
|
||||||
Category() CategoryType
|
Category() CategoryType
|
||||||
Tenant() string
|
|
||||||
Folder(escaped bool) string
|
Folder(escaped bool) string
|
||||||
Folders() Elements
|
Folders() Elements
|
||||||
Item() string
|
Item() string
|
||||||
// UpdateParent updates parent from old to new if the item/folder was
|
|
||||||
// parented by old path
|
// type transformations
|
||||||
UpdateParent(prev, cur Path) bool
|
|
||||||
// PopFront returns a Builder object with the first element (left-side)
|
// ToBuilder returns a Builder instance that represents the current Path.
|
||||||
// removed. As the resulting set of elements is no longer a valid resource
|
ToBuilder() *Builder
|
||||||
// path a Builder is returned instead.
|
|
||||||
PopFront() *Builder
|
|
||||||
// Dir returns a Path object with the right-most element removed if possible.
|
|
||||||
// If removing the right-most element would discard one of the required prefix
|
|
||||||
// elements then an error is returned.
|
|
||||||
Dir() (Path, error)
|
|
||||||
// Elements returns all the elements in the path. This is a temporary function
|
// Elements returns all the elements in the path. This is a temporary function
|
||||||
// and will likely be updated to handle encoded elements instead of clear-text
|
// and will likely be updated to handle encoded elements instead of clear-text
|
||||||
// elements in the future.
|
// elements in the future.
|
||||||
Elements() Elements
|
Elements() Elements
|
||||||
|
// Halves breaks the path into its prefix (tenant, services, resources, category)
|
||||||
|
// and suffix (all parts after the prefix). If either half is empty, that half
|
||||||
|
// returns an empty, non-nil, value.
|
||||||
|
Halves() (*Builder, Elements)
|
||||||
|
// ShortRef returns a short reference representing this path. The short
|
||||||
|
// reference is guaranteed to be unique. No guarantees are made about whether
|
||||||
|
// a short reference can be converted back into the Path that generated it.
|
||||||
|
ShortRef() string
|
||||||
|
|
||||||
|
// mutators
|
||||||
|
|
||||||
// Append returns a new Path object with the given element added to the end of
|
// Append returns a new Path object with the given element added to the end of
|
||||||
// the old Path if possible. If the old Path is an item Path then Append
|
// the old Path if possible. If the old Path is an item Path then Append
|
||||||
// returns an error.
|
// returns an error.
|
||||||
Append(isItem bool, elems ...string) (Path, error)
|
Append(isItem bool, elems ...string) (Path, error)
|
||||||
// AppendItem is a shorthand for Append(true, someItem)
|
// AppendItem is a shorthand for Append(true, someItem)
|
||||||
AppendItem(item string) (Path, error)
|
AppendItem(item string) (Path, error)
|
||||||
// ShortRef returns a short reference representing this path. The short
|
// Dir returns a Path object with the right-most element removed if possible.
|
||||||
// reference is guaranteed to be unique. No guarantees are made about whether
|
// If removing the right-most element would discard one of the required prefix
|
||||||
// a short reference can be converted back into the Path that generated it.
|
// elements then an error is returned.
|
||||||
ShortRef() string
|
Dir() (Path, error)
|
||||||
// ToBuilder returns a Builder instance that represents the current Path.
|
// PopFront returns a Builder object with the first element (left-side)
|
||||||
ToBuilder() *Builder
|
// removed. As the resulting set of elements is no longer a valid resource
|
||||||
// Halves breaks the path into its prefix (tenant, services, resources, category)
|
// path a Builder is returned instead.
|
||||||
// and suffix (all parts after the prefix). If either half is empty, that half
|
PopFront() *Builder
|
||||||
// returns an empty, non-nil, value.
|
// UpdateParent updates parent from old to new if the item/folder was
|
||||||
Halves() (*Builder, Elements)
|
// parented by old path
|
||||||
|
UpdateParent(prev, cur Path) bool
|
||||||
|
|
||||||
// Every path needs to comply with these funcs to ensure that PII
|
// Every path needs to comply with these funcs to ensure that PII
|
||||||
// is appropriately hidden from logging, errors, and other outputs.
|
// is appropriately hidden from logging, errors, and other outputs.
|
||||||
|
|||||||
@ -51,6 +51,26 @@ func (rp dataLayerResourcePath) ServiceResources() []ServiceResource {
|
|||||||
return rp.serviceResources
|
return rp.serviceResources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rp dataLayerResourcePath) PrimaryService() ServiceType {
|
||||||
|
srs := rp.serviceResources
|
||||||
|
|
||||||
|
if len(srs) == 0 {
|
||||||
|
return UnknownService
|
||||||
|
}
|
||||||
|
|
||||||
|
return srs[0].Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rp dataLayerResourcePath) PrimaryProtectedResource() string {
|
||||||
|
srs := rp.serviceResources
|
||||||
|
|
||||||
|
if len(srs) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return srs[0].ProtectedResource
|
||||||
|
}
|
||||||
|
|
||||||
// Category returns the CategoryType embedded in the dataLayerResourcePath.
|
// Category returns the CategoryType embedded in the dataLayerResourcePath.
|
||||||
func (rp dataLayerResourcePath) Category() CategoryType {
|
func (rp dataLayerResourcePath) Category() CategoryType {
|
||||||
return rp.category
|
return rp.category
|
||||||
@ -72,10 +92,16 @@ func (rp dataLayerResourcePath) lastFolderIdx() int {
|
|||||||
return endIdx
|
return endIdx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rp dataLayerResourcePath) prefixLen() int {
|
||||||
|
return 2 + 2*len(rp.serviceResources)
|
||||||
|
}
|
||||||
|
|
||||||
// Folder returns the folder segment embedded in the dataLayerResourcePath.
|
// Folder returns the folder segment embedded in the dataLayerResourcePath.
|
||||||
func (rp dataLayerResourcePath) Folder(escape bool) string {
|
func (rp dataLayerResourcePath) Folder(escape bool) string {
|
||||||
endIdx := rp.lastFolderIdx()
|
endIdx := rp.lastFolderIdx()
|
||||||
if endIdx == 4 {
|
pfxLen := rp.prefixLen()
|
||||||
|
|
||||||
|
if endIdx == pfxLen {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,11 +119,14 @@ func (rp dataLayerResourcePath) Folder(escape bool) string {
|
|||||||
// dataLayerResourcePath.
|
// dataLayerResourcePath.
|
||||||
func (rp dataLayerResourcePath) Folders() Elements {
|
func (rp dataLayerResourcePath) Folders() Elements {
|
||||||
endIdx := rp.lastFolderIdx()
|
endIdx := rp.lastFolderIdx()
|
||||||
if endIdx == 4 {
|
pfxLen := rp.prefixLen()
|
||||||
|
|
||||||
|
// if endIdx == prefix length, there are no folders
|
||||||
|
if endIdx == pfxLen {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return append([]string{}, rp.elements[4:endIdx]...)
|
return append([]string{}, rp.elements[pfxLen:endIdx]...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item returns the item embedded in the dataLayerResourcePath if the path
|
// Item returns the item embedded in the dataLayerResourcePath if the path
|
||||||
|
|||||||
@ -15,14 +15,34 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
testTenant = "aTenant"
|
testTenant = "aTenant"
|
||||||
testUser = "aUser"
|
testProtectedResource = "aProtectedResource"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func elemsWithWithoutItem(elems path.Elements) func(isItem bool) path.Elements {
|
||||||
|
return func(isItem bool) path.Elements {
|
||||||
|
if isItem {
|
||||||
|
return elems[:len(elems)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return elems
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func itemWithWithoutItem(elems path.Elements) func(isItem bool) string {
|
||||||
|
return func(isItem bool) string {
|
||||||
|
if isItem {
|
||||||
|
return elems[len(elems)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Purposely doesn't have characters that need escaping so it can be easily
|
// Purposely doesn't have characters that need escaping so it can be easily
|
||||||
// computed using strings.Join().
|
// computed using strings.Join().
|
||||||
rest = []string{"some", "folder", "path", "with", "possible", "item"}
|
rest = path.Elements{"some", "folder", "path", "with", "possible", "item"}
|
||||||
|
|
||||||
missingInfo = []struct {
|
missingInfo = []struct {
|
||||||
name string
|
name string
|
||||||
@ -33,7 +53,7 @@ var (
|
|||||||
{
|
{
|
||||||
name: "NoTenant",
|
name: "NoTenant",
|
||||||
tenant: "",
|
tenant: "",
|
||||||
user: testUser,
|
user: testProtectedResource,
|
||||||
rest: rest,
|
rest: rest,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -45,7 +65,7 @@ var (
|
|||||||
{
|
{
|
||||||
name: "NoFolderOrItem",
|
name: "NoFolderOrItem",
|
||||||
tenant: testTenant,
|
tenant: testTenant,
|
||||||
user: testUser,
|
user: testProtectedResource,
|
||||||
rest: nil,
|
rest: nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -70,60 +90,193 @@ var (
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set of acceptable service/category mixtures.
|
// Set of acceptable service[/subservice]/category mixtures.
|
||||||
serviceCategories = []struct {
|
serviceCategories = []struct {
|
||||||
service path.ServiceType
|
name string
|
||||||
category path.CategoryType
|
primaryService path.ServiceType
|
||||||
pathFunc func(pb *path.Builder, tenant, user string, isItem bool) (path.Path, error)
|
category path.CategoryType
|
||||||
|
pathFunc func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error)
|
||||||
|
expectFolders func(expect path.Elements) func(isItem bool) path.Elements
|
||||||
|
expectItem func(expect path.Elements) func(isItem bool) string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
service: path.ExchangeService,
|
name: path.ExchangeService.String() + path.EmailCategory.String(),
|
||||||
category: path.EmailCategory,
|
primaryService: path.ExchangeService,
|
||||||
pathFunc: func(pb *path.Builder, tenant, user string, isItem bool) (path.Path, error) {
|
category: path.EmailCategory,
|
||||||
return pb.ToDataLayerExchangePathForCategory(tenant, user, path.EmailCategory, isItem)
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.ExchangeService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
},
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
service: path.ExchangeService,
|
name: path.ExchangeService.String() + path.ContactsCategory.String(),
|
||||||
category: path.ContactsCategory,
|
primaryService: path.ExchangeService,
|
||||||
pathFunc: func(pb *path.Builder, tenant, user string, isItem bool) (path.Path, error) {
|
category: path.ContactsCategory,
|
||||||
return pb.ToDataLayerExchangePathForCategory(tenant, user, path.ContactsCategory, isItem)
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.ExchangeService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
},
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
service: path.ExchangeService,
|
name: path.ExchangeService.String() + path.EventsCategory.String(),
|
||||||
category: path.EventsCategory,
|
primaryService: path.ExchangeService,
|
||||||
pathFunc: func(pb *path.Builder, tenant, user string, isItem bool) (path.Path, error) {
|
category: path.EventsCategory,
|
||||||
return pb.ToDataLayerExchangePathForCategory(tenant, user, path.EventsCategory, isItem)
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.ExchangeService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
},
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
service: path.OneDriveService,
|
name: path.OneDriveService.String() + path.FilesCategory.String(),
|
||||||
category: path.FilesCategory,
|
primaryService: path.OneDriveService,
|
||||||
pathFunc: func(pb *path.Builder, tenant, user string, isItem bool) (path.Path, error) {
|
category: path.FilesCategory,
|
||||||
return pb.ToDataLayerOneDrivePath(tenant, user, isItem)
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.OneDriveService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
},
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
service: path.SharePointService,
|
name: path.SharePointService.String() + path.LibrariesCategory.String(),
|
||||||
category: path.LibrariesCategory,
|
primaryService: path.SharePointService,
|
||||||
pathFunc: func(pb *path.Builder, tenant, site string, isItem bool) (path.Path, error) {
|
category: path.LibrariesCategory,
|
||||||
return pb.ToDataLayerSharePointPath(tenant, site, path.LibrariesCategory, isItem)
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.SharePointService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
},
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
service: path.SharePointService,
|
name: path.SharePointService.String() + path.ListsCategory.String(),
|
||||||
category: path.ListsCategory,
|
primaryService: path.SharePointService,
|
||||||
pathFunc: func(pb *path.Builder, tenant, site string, isItem bool) (path.Path, error) {
|
category: path.ListsCategory,
|
||||||
return pb.ToDataLayerSharePointPath(tenant, site, path.ListsCategory, isItem)
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.SharePointService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
},
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
service: path.SharePointService,
|
name: path.SharePointService.String() + path.PagesCategory.String(),
|
||||||
category: path.PagesCategory,
|
primaryService: path.SharePointService,
|
||||||
pathFunc: func(pb *path.Builder, tenant, site string, isItem bool) (path.Path, error) {
|
category: path.PagesCategory,
|
||||||
return pb.ToDataLayerSharePointPath(tenant, site, path.PagesCategory, isItem)
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.SharePointService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
},
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: path.GroupsService.String() + path.UnknownCategory.String(),
|
||||||
|
primaryService: path.GroupsService,
|
||||||
|
category: path.UnknownCategory,
|
||||||
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(path.GroupsService, primaryResource)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: path.GroupsService.String() + path.SharePointService.String() + path.UnknownCategory.String(),
|
||||||
|
primaryService: path.GroupsService,
|
||||||
|
category: path.LibrariesCategory,
|
||||||
|
pathFunc: func(
|
||||||
|
tenant, primaryResource string,
|
||||||
|
isItem bool,
|
||||||
|
suffix path.Elements,
|
||||||
|
) (path.Path, error) {
|
||||||
|
srs, err := path.NewServiceResources(
|
||||||
|
path.GroupsService,
|
||||||
|
primaryResource,
|
||||||
|
path.SharePointService,
|
||||||
|
"secondaryProtectedResource")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.Build(tenant, srs, path.PagesCategory, isItem, suffix...)
|
||||||
|
},
|
||||||
|
expectFolders: elemsWithWithoutItem,
|
||||||
|
expectItem: itemWithWithoutItem,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -142,22 +295,13 @@ func (suite *DataLayerResourcePath) SetupSuite() {
|
|||||||
|
|
||||||
func (suite *DataLayerResourcePath) TestMissingInfoErrors() {
|
func (suite *DataLayerResourcePath) TestMissingInfoErrors() {
|
||||||
for _, types := range serviceCategories {
|
for _, types := range serviceCategories {
|
||||||
suite.Run(types.service.String()+types.category.String(), func() {
|
suite.Run(types.primaryService.String()+types.category.String(), func() {
|
||||||
for _, m := range modes {
|
for _, m := range modes {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(m.name, func() {
|
||||||
for _, test := range missingInfo {
|
for _, test := range missingInfo {
|
||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
_, err := types.pathFunc(test.tenant, test.user, m.isItem, rest)
|
||||||
|
assert.Error(suite.T(), err, clues.ToCore(err))
|
||||||
b := path.Builder{}.Append(test.rest...)
|
|
||||||
|
|
||||||
_, err := types.pathFunc(
|
|
||||||
b,
|
|
||||||
test.tenant,
|
|
||||||
test.user,
|
|
||||||
m.isItem,
|
|
||||||
)
|
|
||||||
assert.Error(t, err)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -167,31 +311,23 @@ func (suite *DataLayerResourcePath) TestMissingInfoErrors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DataLayerResourcePath) TestMailItemNoFolder() {
|
func (suite *DataLayerResourcePath) TestMailItemNoFolder() {
|
||||||
item := "item"
|
for _, test := range serviceCategories {
|
||||||
b := path.Builder{}.Append(item)
|
suite.Run(test.name, func() {
|
||||||
|
|
||||||
for _, types := range serviceCategories {
|
|
||||||
suite.Run(types.service.String()+types.category.String(), func() {
|
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
p, err := types.pathFunc(
|
p, err := test.pathFunc(testTenant, testProtectedResource, true, path.Elements{"item"})
|
||||||
b,
|
|
||||||
testTenant,
|
|
||||||
testUser,
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
assert.Empty(t, p.Folder(false))
|
assert.Empty(t, p.Folder(false))
|
||||||
assert.Empty(t, p.Folders())
|
assert.Empty(t, p.Folders())
|
||||||
assert.Equal(t, item, p.Item())
|
assert.Equal(t, test.expectItem(path.Elements{"item"})(true), p.Item())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DataLayerResourcePath) TestPopFront() {
|
func (suite *DataLayerResourcePath) TestPopFront() {
|
||||||
expected := path.Builder{}.Append(append(
|
expected := path.Builder{}.Append(append(
|
||||||
[]string{path.ExchangeService.String(), testUser, path.EmailCategory.String()},
|
[]string{path.ExchangeService.String(), testProtectedResource, path.EmailCategory.String()},
|
||||||
rest...,
|
rest...,
|
||||||
)...)
|
)...)
|
||||||
|
|
||||||
@ -202,7 +338,7 @@ func (suite *DataLayerResourcePath) TestPopFront() {
|
|||||||
pb := path.Builder{}.Append(rest...)
|
pb := path.Builder{}.Append(rest...)
|
||||||
p, err := pb.ToDataLayerExchangePathForCategory(
|
p, err := pb.ToDataLayerExchangePathForCategory(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
testProtectedResource,
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
m.isItem,
|
m.isItem,
|
||||||
)
|
)
|
||||||
@ -218,7 +354,7 @@ func (suite *DataLayerResourcePath) TestDir() {
|
|||||||
elements := []string{
|
elements := []string{
|
||||||
testTenant,
|
testTenant,
|
||||||
path.ExchangeService.String(),
|
path.ExchangeService.String(),
|
||||||
testUser,
|
testProtectedResource,
|
||||||
path.EmailCategory.String(),
|
path.EmailCategory.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +363,7 @@ func (suite *DataLayerResourcePath) TestDir() {
|
|||||||
pb := path.Builder{}.Append(rest...)
|
pb := path.Builder{}.Append(rest...)
|
||||||
p, err := pb.ToDataLayerExchangePathForCategory(
|
p, err := pb.ToDataLayerExchangePathForCategory(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
testProtectedResource,
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
m.isItem,
|
m.isItem,
|
||||||
)
|
)
|
||||||
@ -391,7 +527,7 @@ func (suite *DataLayerResourcePath) TestToExchangePathForCategory() {
|
|||||||
|
|
||||||
p, err := b.ToDataLayerExchangePathForCategory(
|
p, err := b.ToDataLayerExchangePathForCategory(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
testProtectedResource,
|
||||||
test.category,
|
test.category,
|
||||||
m.isItem)
|
m.isItem)
|
||||||
test.check(t, err, clues.ToCore(err))
|
test.check(t, err, clues.ToCore(err))
|
||||||
@ -401,9 +537,9 @@ func (suite *DataLayerResourcePath) TestToExchangePathForCategory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, testTenant, p.Tenant())
|
assert.Equal(t, testTenant, p.Tenant())
|
||||||
assert.Equal(t, path.ExchangeService, p.ServiceResources()[0].Service)
|
assert.Equal(t, path.ExchangeService, p.PrimaryService())
|
||||||
assert.Equal(t, test.category, p.Category())
|
assert.Equal(t, test.category, p.Category())
|
||||||
assert.Equal(t, testUser, p.ServiceResources()[0].ProtectedResource)
|
assert.Equal(t, testProtectedResource, p.PrimaryProtectedResource())
|
||||||
assert.Equal(t, strings.Join(m.expectedFolders, "/"), p.Folder(false))
|
assert.Equal(t, strings.Join(m.expectedFolders, "/"), p.Folder(false))
|
||||||
assert.Equal(t, path.Elements(m.expectedFolders), p.Folders())
|
assert.Equal(t, path.Elements(m.expectedFolders), p.Folders())
|
||||||
assert.Equal(t, m.expectedItem, p.Item())
|
assert.Equal(t, m.expectedItem, p.Item())
|
||||||
@ -416,7 +552,8 @@ func (suite *DataLayerResourcePath) TestToExchangePathForCategory() {
|
|||||||
type PopulatedDataLayerResourcePath struct {
|
type PopulatedDataLayerResourcePath struct {
|
||||||
tester.Suite
|
tester.Suite
|
||||||
// Bool value is whether the path is an item path or a folder path.
|
// Bool value is whether the path is an item path or a folder path.
|
||||||
paths map[bool]path.Path
|
serviceCategoriesToIsItemToPath map[string]map[bool]path.Path
|
||||||
|
isItemToPath map[bool]path.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPopulatedDataLayerResourcePath(t *testing.T) {
|
func TestPopulatedDataLayerResourcePath(t *testing.T) {
|
||||||
@ -424,98 +561,109 @@ func TestPopulatedDataLayerResourcePath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) SetupSuite() {
|
func (suite *PopulatedDataLayerResourcePath) SetupSuite() {
|
||||||
suite.paths = make(map[bool]path.Path, 2)
|
suite.serviceCategoriesToIsItemToPath = map[string]map[bool]path.Path{}
|
||||||
base := path.Builder{}.Append(rest...)
|
|
||||||
|
|
||||||
for _, t := range []bool{true, false} {
|
for _, sc := range serviceCategories {
|
||||||
p, err := base.ToDataLayerExchangePathForCategory(
|
m := make(map[bool]path.Path, 2)
|
||||||
testTenant,
|
suite.serviceCategoriesToIsItemToPath[sc.name] = m
|
||||||
testUser,
|
|
||||||
path.EmailCategory,
|
|
||||||
t,
|
|
||||||
)
|
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
|
||||||
|
|
||||||
suite.paths[t] = p
|
for _, is := range []bool{true, false} {
|
||||||
|
p, err := sc.pathFunc(testTenant, testProtectedResource, is, rest)
|
||||||
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
|
|
||||||
|
suite.serviceCategoriesToIsItemToPath[sc.name][is] = p
|
||||||
|
suite.isItemToPath[is] = p
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) TestTenant() {
|
func (suite *PopulatedDataLayerResourcePath) TestTenant() {
|
||||||
for _, m := range modes {
|
for _, test := range serviceCategories {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
for _, m := range modes {
|
||||||
|
suite.Run(m.name, func() {
|
||||||
assert.Equal(t, testTenant, suite.paths[m.isItem].Tenant())
|
p := suite.serviceCategoriesToIsItemToPath[test.name][m.isItem]
|
||||||
|
assert.Equal(suite.T(), testTenant, p.Tenant())
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) TestService() {
|
func (suite *PopulatedDataLayerResourcePath) TestPrimaryService() {
|
||||||
for _, m := range modes {
|
for _, test := range serviceCategories {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
for _, m := range modes {
|
||||||
|
suite.Run(m.name, func() {
|
||||||
assert.Equal(
|
p := suite.serviceCategoriesToIsItemToPath[test.name][m.isItem]
|
||||||
t,
|
assert.Equal(suite.T(), test.primaryService, p.PrimaryService())
|
||||||
path.ExchangeService,
|
})
|
||||||
suite.paths[m.isItem].ServiceResources()[0].Service)
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) TestCategory() {
|
func (suite *PopulatedDataLayerResourcePath) TestCategory() {
|
||||||
for _, m := range modes {
|
for _, test := range serviceCategories {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
for _, m := range modes {
|
||||||
|
suite.Run(m.name, func() {
|
||||||
assert.Equal(t, path.EmailCategory, suite.paths[m.isItem].Category())
|
p := suite.serviceCategoriesToIsItemToPath[test.name][m.isItem]
|
||||||
|
assert.Equal(suite.T(), test.category, p.Category())
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) TestResourceOwner() {
|
func (suite *PopulatedDataLayerResourcePath) TestPrimaryProtectedResource() {
|
||||||
for _, m := range modes {
|
for _, test := range serviceCategories {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
for _, m := range modes {
|
||||||
|
suite.Run(m.name, func() {
|
||||||
assert.Equal(
|
p := suite.serviceCategoriesToIsItemToPath[test.name][m.isItem]
|
||||||
t,
|
assert.Equal(suite.T(), testProtectedResource, p.PrimaryProtectedResource())
|
||||||
testUser,
|
})
|
||||||
suite.paths[m.isItem].ServiceResources()[0].ProtectedResource)
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) TestFolder() {
|
func (suite *PopulatedDataLayerResourcePath) TestFolder() {
|
||||||
for _, m := range modes {
|
for _, test := range serviceCategories {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
for _, m := range modes {
|
||||||
|
suite.Run(m.name, func() {
|
||||||
assert.Equal(
|
p := suite.serviceCategoriesToIsItemToPath[test.name][m.isItem]
|
||||||
t,
|
assert.Equal(suite.T(), test.expectFolders(rest)(m.isItem).String(), p.Folder(true))
|
||||||
strings.Join(m.expectedFolders, "/"),
|
})
|
||||||
suite.paths[m.isItem].Folder(false),
|
}
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) TestFolders() {
|
func (suite *PopulatedDataLayerResourcePath) TestFolders() {
|
||||||
for _, m := range modes {
|
for _, test := range serviceCategories {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
for _, m := range modes {
|
||||||
|
suite.Run(m.name, func() {
|
||||||
assert.Equal(t, path.Elements(m.expectedFolders), suite.paths[m.isItem].Folders())
|
p := suite.serviceCategoriesToIsItemToPath[test.name][m.isItem]
|
||||||
|
assert.Equal(suite.T(), test.expectFolders(rest)(m.isItem), p.Folders())
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PopulatedDataLayerResourcePath) TestItem() {
|
func (suite *PopulatedDataLayerResourcePath) TestItem() {
|
||||||
for _, m := range modes {
|
for _, test := range serviceCategories {
|
||||||
suite.Run(m.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
for _, m := range modes {
|
||||||
|
suite.Run(m.name, func() {
|
||||||
assert.Equal(t, m.expectedItem, suite.paths[m.isItem].Item())
|
p := suite.serviceCategoriesToIsItemToPath[test.name][m.isItem]
|
||||||
|
assert.Equal(suite.T(), test.expectItem(rest)(m.isItem), p.Item())
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,8 +688,7 @@ func (suite *PopulatedDataLayerResourcePath) TestAppend() {
|
|||||||
hasItem: false,
|
hasItem: false,
|
||||||
expectedFolder: strings.Join(
|
expectedFolder: strings.Join(
|
||||||
append(append([]string{}, rest...), newElement),
|
append(append([]string{}, rest...), newElement),
|
||||||
"/",
|
"/"),
|
||||||
),
|
|
||||||
expectedItem: "",
|
expectedItem: "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -552,7 +699,7 @@ func (suite *PopulatedDataLayerResourcePath) TestAppend() {
|
|||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
newPath, err := suite.paths[m.isItem].Append(test.hasItem, newElement)
|
newPath, err := suite.isItemToPath[m.isItem].Append(test.hasItem, newElement)
|
||||||
|
|
||||||
// Items don't allow appending.
|
// Items don't allow appending.
|
||||||
if m.isItem {
|
if m.isItem {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user