exchange.Collection addition of job field to struct (#434)

`exchange.Collection` field **jobs** `type: [] string` added to struct
This commit is contained in:
Danny 2022-07-28 11:50:55 -04:00 committed by GitHub
parent 402b3aae06
commit 987980510c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -37,6 +37,9 @@ type Collection struct {
// M365 user
user string // M365 user
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.
//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{
user: aUser,
data: make(chan data.Stream, collectionChannelBufferSize),
jobs: make([]string, 0),
fullPath: pathRepresentation,
}
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) {
eoc.data <- newData
}
// 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 will be removed as the channel will be filled from calls from exchange.Collection
func (eoc *Collection) FinishPopulation() {
if eoc.data != nil {
close(eoc.data)

View File

@ -93,3 +93,14 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataCollection_Items() {
}
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))
}