From 390493d402ebed3b8b94966be9e33615d6364cf6 Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Mon, 11 Sep 2023 11:05:47 +0200 Subject: [PATCH] Test state RunOnEventLoop --- grpc/stream_test.go | 12 +++--------- grpc/teststate_test.go | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/grpc/stream_test.go b/grpc/stream_test.go index 5a4edb2..5fff7a8 100644 --- a/grpc/stream_test.go +++ b/grpc/stream_test.go @@ -82,9 +82,7 @@ func TestStream_RequestHeaders(t *testing.T) { ts.ToVUContext() - val, err = ts.Run(vuString.code) - - ts.EventLoop.WaitOnRegistered() + val, err = ts.RunOnEventLoop(vuString.code) assertResponse(t, vuString, err, val, ts) @@ -162,9 +160,7 @@ func TestStream_ErrorHandling(t *testing.T) { ts.ToVUContext() - val, err = ts.Run(vuString.code) - - ts.EventLoop.WaitOnRegistered() + val, err = ts.RunOnEventLoop(vuString.code) assertResponse(t, vuString, err, val, ts) @@ -255,9 +251,7 @@ func TestStream_ReceiveAllServerResponsesAfterEnd(t *testing.T) { ts.ToVUContext() - val, err = ts.Run(vuString.code) - - ts.EventLoop.WaitOnRegistered() + val, err = ts.RunOnEventLoop(vuString.code) assertResponse(t, vuString, err, val, ts) diff --git a/grpc/teststate_test.go b/grpc/teststate_test.go index d83f1ec..f3bc669 100644 --- a/grpc/teststate_test.go +++ b/grpc/teststate_test.go @@ -86,6 +86,11 @@ func (ts *testState) Run(code string) (goja.Value, error) { return ts.VU.Runtime().RunString(ts.httpBin.Replacer.Replace(code)) } +// RunOnEventLoop replaces the httpbin address and run the code on event loop +func (ts *testState) RunOnEventLoop(code string) (goja.Value, error) { + return ts.Runtime.RunOnEventLoop(ts.httpBin.Replacer.Replace(code)) +} + // newTestState creates a new test state. func newTestState(t *testing.T) testState { t.Helper()