exchange.Collection addition of job field to struct (#434)
`exchange.Collection` field **jobs** `type: [] string` added to struct
This commit is contained in:
parent
402b3aae06
commit
987980510c
@ -37,6 +37,9 @@ type Collection struct {
|
|||||||
// M365 user
|
// M365 user
|
||||||
user string // M365 user
|
user string // M365 user
|
||||||
data chan data.Stream
|
data chan data.Stream
|
||||||
|
// jobs represents items from the inventory of M365 objectIds whose information
|
||||||
|
// is desired to be sent through the data channel for eventual storage
|
||||||
|
jobs []string
|
||||||
|
|
||||||
// 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"})
|
//The original request can be gleaned from the slice. (e.g. {<tenant ID>, <user ID>, "emails"})
|
||||||
@ -48,17 +51,25 @@ func NewCollection(aUser string, pathRepresentation []string) Collection {
|
|||||||
collection := Collection{
|
collection := Collection{
|
||||||
user: aUser,
|
user: aUser,
|
||||||
data: make(chan data.Stream, collectionChannelBufferSize),
|
data: make(chan data.Stream, collectionChannelBufferSize),
|
||||||
|
jobs: make([]string, 0),
|
||||||
fullPath: pathRepresentation,
|
fullPath: pathRepresentation,
|
||||||
}
|
}
|
||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddJob appends additional objectID to job field job
|
||||||
|
func (eoc *Collection) AddJob(objID string) {
|
||||||
|
eoc.jobs = append(eoc.jobs, objID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PopulateCollection TODO: remove after async functionilty completed
|
||||||
func (eoc *Collection) PopulateCollection(newData *Stream) {
|
func (eoc *Collection) PopulateCollection(newData *Stream) {
|
||||||
eoc.data <- newData
|
eoc.data <- newData
|
||||||
}
|
}
|
||||||
|
|
||||||
// FinishPopulation is used to indicate data population of the collection is complete
|
// FinishPopulation is used to indicate data population of the collection is complete
|
||||||
// TODO: This should be an internal method once we move the message retrieval logic into `ExchangeDataCollection`
|
// TODO: This should be an internal method once we move the message retrieval logic into `ExchangeDataCollection`
|
||||||
|
// TODO: This will be removed as the channel will be filled from calls from exchange.Collection
|
||||||
func (eoc *Collection) FinishPopulation() {
|
func (eoc *Collection) FinishPopulation() {
|
||||||
if eoc.data != nil {
|
if eoc.data != nil {
|
||||||
close(eoc.data)
|
close(eoc.data)
|
||||||
|
|||||||
@ -93,3 +93,14 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_Items() {
|
|||||||
}
|
}
|
||||||
suite.Equal(count, expected)
|
suite.Equal(count, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *ExchangeDataCollectionSuite) TestExchangeCollection_AddJob() {
|
||||||
|
eoc := NewCollection("Dexter", []string{"Today", "is", "was", "different"})
|
||||||
|
suite.Zero(len(eoc.jobs))
|
||||||
|
shopping := []string{"tomotoes", "potatoes", "pasta", "ice tea"}
|
||||||
|
for _, item := range shopping {
|
||||||
|
eoc.AddJob(item)
|
||||||
|
}
|
||||||
|
suite.Equal(len(shopping), len(eoc.jobs))
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user