Add FullPath() to DataCollection interface (#164)
* Add FullPath() to interface * Simple test for FullPath
This commit is contained in:
parent
5dcb2b7579
commit
042f3eaaee
@ -11,6 +11,11 @@ type DataCollection interface {
|
||||
// Returns either the next item in the collection or an error if one occurred.
|
||||
// If not more items are available in the collection, returns (nil, nil).
|
||||
NextItem() (DataStream, error)
|
||||
// FullPath returns a slice of strings that act as metadata tags for this
|
||||
// DataCollection. Returned items should be ordered from most generic to least
|
||||
// generic. For example, a DataCollection for emails from a specific user
|
||||
// would be {"<tenant id>", "<user ID>", "emails"}.
|
||||
FullPath() []string
|
||||
}
|
||||
|
||||
// DataStream represents a single item within a DataCollection
|
||||
@ -32,9 +37,9 @@ type ExchangeDataCollection struct {
|
||||
// TODO: We would want to replace this with a channel so that we
|
||||
// don't need to wait for all data to be retrieved before reading it out
|
||||
data []ExchangeData
|
||||
// FullPath is the slice representation of the action context passed down through the hierarchy.
|
||||
// fullPath is the slice representation of the action context passed down through the hierarchy.
|
||||
//The original request can be gleaned from the slice. (e.g. {<tenant ID>, <user ID>, "emails"})
|
||||
FullPath []string
|
||||
fullPath []string
|
||||
}
|
||||
|
||||
// NewExchangeDataCollection creates an ExchangeDataCollection where
|
||||
@ -43,7 +48,7 @@ func NewExchangeDataCollection(aUser string, pathRepresentation []string) Exchan
|
||||
collection := ExchangeDataCollection{
|
||||
user: aUser,
|
||||
data: make([]ExchangeData, 0),
|
||||
FullPath: pathRepresentation,
|
||||
fullPath: pathRepresentation,
|
||||
}
|
||||
return collection
|
||||
}
|
||||
@ -63,6 +68,10 @@ func (*ExchangeDataCollection) NextItem() (DataStream, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (ec *ExchangeDataCollection) FullPath() []string {
|
||||
return append([]string{}, ec.fullPath...)
|
||||
}
|
||||
|
||||
// ExchangeData represents a single item retrieved from exchange
|
||||
type ExchangeData struct {
|
||||
id string
|
||||
|
||||
@ -25,3 +25,11 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataReader() {
|
||||
buf.ReadFrom(ed.ToReader())
|
||||
assert.Equal(suite.T(), buf.Bytes(), m)
|
||||
}
|
||||
|
||||
func (suite *ExchangeDataCollectionSuite) TestExchangeData_FullPath() {
|
||||
user := "a-user"
|
||||
fullPath := []string{"a-tenant", user, "emails"}
|
||||
edc := NewExchangeDataCollection(user, fullPath)
|
||||
|
||||
assert.Equal(suite.T(), edc.FullPath(), fullPath)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user