Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Test state RunOnEventLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Sep 11, 2023
1 parent d32a7db commit 390493d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 3 additions & 9 deletions grpc/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions grpc/teststate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 390493d

Please sign in to comment.