160
}
161
162
>
func (h HistoryRequire) WaitForHistoryEventsSuffix(expectedHistorySuffix string, actualHistoryEventsReader HistoryEventsReader, waitFor time.Duration, tick time.Duration) {
history_require.go
163
>
if th, ok := h.t.(helper); ok {
164
>
th.Helper()
165
>
}
166
167
>
expectedHistoryEvents, expectedEventsAttributes := h.parseHistory(expectedHistorySuffix)
history_require.go
168
>
169
>
expectedCompactHistory := h.formatHistoryEvents(expectedHistoryEvents, true)
170
>
171
>
var actualHistoryEvents []*historypb.HistoryEvent
172
>
require.EventuallyWithT(h.t, func(t *assert.CollectT) {
173
>
actualHistoryEvents = actualHistoryEventsReader()
174
>
175
>
require.GreaterOrEqualf(t, len(actualHistoryEvents), len(expectedHistoryEvents),
176
>
"Length of actual history(%d) must be greater or equal to the length of expected history suffix(%d) - actual history: \n%v",
177
>
len(actualHistoryEvents), len(expectedHistoryEvents), h.formatHistoryEvents(actualHistoryEvents, true))
178
>
179
>
actualHistoryEvents = actualHistoryEvents[len(actualHistoryEvents)-len(expectedHistoryEvents):]
180
>
actualHistoryEvents = h.sanitizeActualHistoryEventsForEquals(expectedHistoryEvents, actualHistoryEvents)
181
>
actualCompactHistory := h.formatHistoryEvents(actualHistoryEvents, true)
182
>
183
>
require.Equalf(t, expectedCompactHistory, actualCompactHistory,
184
>
"Expected history suffix is not found in actual history. Expected suffix:\n%s\nLast actual:\n%s",
185
>
expectedCompactHistory, actualCompactHistory)
186
>
}, waitFor, tick)
187
188
// TODO: Now if expected sequence of events is reached, all attributes must match.