From bca9a3686253bd1d2ea57af099ba3620002a0b20 Mon Sep 17 00:00:00 2001 From: Ashlie Martinez Date: Wed, 2 Nov 2022 16:52:47 -0700 Subject: [PATCH] Fixup setting mod times in mock collection --- .../connector/mockconnector/mock_data_collection.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/internal/connector/mockconnector/mock_data_collection.go b/src/internal/connector/mockconnector/mock_data_collection.go index f72c884838..78aa80e1c0 100644 --- a/src/internal/connector/mockconnector/mock_data_collection.go +++ b/src/internal/connector/mockconnector/mock_data_collection.go @@ -19,6 +19,7 @@ type MockExchangeDataCollection struct { messageCount int Data [][]byte Names []string + ModTimes []time.Time } var ( @@ -36,12 +37,15 @@ func NewMockExchangeCollection(pathRepresentation path.Path, numMessagesToReturn messageCount: numMessagesToReturn, Data: [][]byte{}, Names: []string{}, + ModTimes: []time.Time{}, } + baseTime := time.Now() for i := 0; i < c.messageCount; i++ { // We can plug in whatever data we want here (can be an io.Reader to a test data file if needed) 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)) } return c @@ -100,7 +104,7 @@ func (medc *MockExchangeDataCollection) Items() <-chan data.Stream { ID: medc.Names[i], Reader: io.NopCloser(bytes.NewReader(medc.Data[i])), size: int64(len(medc.Data[i])), - ModifiedTime: time.Now(), + modifiedTime: medc.ModTimes[i], } } }() @@ -114,7 +118,7 @@ type MockExchangeData struct { Reader io.ReadCloser ReadErr error size int64 - ModifiedTime time.Time + modifiedTime time.Time } func (med *MockExchangeData) UUID() string { @@ -144,7 +148,7 @@ func (med *MockExchangeData) Size() int64 { } func (med *MockExchangeData) ModTime() time.Time { - return med.ModifiedTime + return med.modifiedTime } type errReader struct {