-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
More often than not we would like to do
go client.Put(...)
in our code.
But this creates issues with testing such code. Namely there is a problem with syncing on the logging code so that test can reliably check of a certain message has been Put.
I've introduced this PR to enable the general possibility of such a test. But test code that tests for the fact that 2 messages have been pushed now looks like this:
timeout := make(chan bool, 1)
go func() {
time.Sleep(1 * time.Second)
timeout <- true
}()
select {
case <-gTritonLogger.Channel:
go func() {
time.Sleep(1 * time.Second)
timeout <- true
}()
select {
case <-gTritonLogger.Channel:
case <-timeout:
assert.Fail(t,"GetQuotes has not been logged to tritonD")
}
case <-timeout:
assert.Fail(t,"Place Quote has not been logged to tritonD")
}
tData := gTritonLogger.StreamData
assert.Equal(t, 2, len(tData))
singlPQLogEntry, ok := tData[GetQuotesSinglePlaceEventName]
assert.True(t, ok)
assert.EqualValues(t, pq.QuoteUUID, singlPQLogEntry[0]["request_uuid"])
getQuotesLogEntry, ok := tData[GetQuotesEventName]
assert.True(t, ok)
assert.EqualValues(t, pq.RequestUUID, getQuotesLogEntry[0]["request_uuid"])
Something need to be done about MockClient so it is easier to test async usages of TritonD Client.
Metadata
Metadata
Assignees
Labels
No labels