Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MockClient Async Capabilities #17

Open
mikhailkolesnik opened this issue Oct 17, 2017 · 0 comments
Open

MockClient Async Capabilities #17

mikhailkolesnik opened this issue Oct 17, 2017 · 0 comments

Comments

@mikhailkolesnik
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant