From 8442175a5d52e466ddd667df9c32b9a55110647a Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Tue, 13 Dec 2022 12:41:53 -0800 Subject: [PATCH] Allow updating and returning non-default values (#1794) ## Description Update mockcollection to allow returning non-default values for attributes like PreviousPath() and whether an item has been deleted. ## Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [ ] :computer: CI/Deployment - [x] :hamster: Trivial/Minor ## Issue(s) * #1740 ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .../mockconnector/mock_data_collection.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/internal/connector/mockconnector/mock_data_collection.go b/src/internal/connector/mockconnector/mock_data_collection.go index 0f44e95c5..e7c5d83ae 100644 --- a/src/internal/connector/mockconnector/mock_data_collection.go +++ b/src/internal/connector/mockconnector/mock_data_collection.go @@ -20,6 +20,9 @@ type MockExchangeDataCollection struct { Data [][]byte Names []string ModTimes []time.Time + ColState data.CollectionState + PrevPath path.Path + DeletedItems []bool } var ( @@ -38,6 +41,7 @@ func NewMockExchangeCollection(pathRepresentation path.Path, numMessagesToReturn Data: [][]byte{}, Names: []string{}, ModTimes: []time.Time{}, + DeletedItems: []bool{}, } baseTime := time.Now() @@ -46,6 +50,7 @@ func NewMockExchangeCollection(pathRepresentation path.Path, numMessagesToReturn c.Data = append(c.Data, GetMockMessageBytes("From: NewMockExchangeCollection")) c.Names = append(c.Names, uuid.NewString()) c.ModTimes = append(c.ModTimes, baseTime.Add(1*time.Hour)) + c.DeletedItems = append(c.DeletedItems, false) } return c @@ -91,14 +96,12 @@ func (medc *MockExchangeDataCollection) FullPath() path.Path { return medc.fullPath } -// TODO(ashmrtn): May want to allow setting this in the future for testing. func (medc MockExchangeDataCollection) PreviousPath() path.Path { - return nil + return medc.PrevPath } -// TODO(ashmrtn): May want to allow setting this in the future for testing. func (medc MockExchangeDataCollection) State() data.CollectionState { - return data.NewState + return medc.ColState } // Items returns a channel that has the next items in the collection. The @@ -115,6 +118,7 @@ func (medc *MockExchangeDataCollection) Items() <-chan data.Stream { Reader: io.NopCloser(bytes.NewReader(medc.Data[i])), size: int64(len(medc.Data[i])), modifiedTime: medc.ModTimes[i], + deleted: medc.DeletedItems[i], } } }() @@ -129,15 +133,15 @@ type MockExchangeData struct { ReadErr error size int64 modifiedTime time.Time + deleted bool } func (med *MockExchangeData) UUID() string { return med.ID } -// TODO(ashmrtn): May want to allow setting this in the future for testing. func (med MockExchangeData) Deleted() bool { - return false + return med.deleted } func (med *MockExchangeData) ToReader() io.ReadCloser {