Skip to content

Commit

Permalink
fix failing race
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhoonbang committed Sep 30, 2024
1 parent 6936a12 commit 27bfa02
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/services/gateway/handlers/webapicapabilities/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func TestHandler_SendHTTPMessageToClient(t *testing.T) {

don.EXPECT().SendToNode(mock.Anything, nodes[0].Address, mock.MatchedBy(func(m *api.Message) bool {
var payload TargetResponsePayload
err = json.Unmarshal(m.Body.Payload, &payload)
if err != nil {
err2 := json.Unmarshal(m.Body.Payload, &payload)
if err2 != nil {
return false
}
return "123" == m.Body.MessageId &&
Expand Down Expand Up @@ -117,8 +117,8 @@ func TestHandler_SendHTTPMessageToClient(t *testing.T) {

don.EXPECT().SendToNode(mock.Anything, nodes[0].Address, mock.MatchedBy(func(m *api.Message) bool {
var payload TargetResponsePayload
err = json.Unmarshal(m.Body.Payload, &payload)
if err != nil {
err2 := json.Unmarshal(m.Body.Payload, &payload)
if err2 != nil {
return false
}
return "123" == m.Body.MessageId &&
Expand All @@ -134,7 +134,7 @@ func TestHandler_SendHTTPMessageToClient(t *testing.T) {
require.NoError(t, err)

require.Eventually(t, func() bool {
// ensure all goroutines close
// // ensure all goroutines close
err2 := handler.Close()
require.NoError(t, err2)
return httpClient.AssertExpectations(t) && don.AssertExpectations(t)
Expand All @@ -146,8 +146,8 @@ func TestHandler_SendHTTPMessageToClient(t *testing.T) {

don.EXPECT().SendToNode(mock.Anything, nodes[0].Address, mock.MatchedBy(func(m *api.Message) bool {
var payload TargetResponsePayload
err = json.Unmarshal(m.Body.Payload, &payload)
if err != nil {
err2 := json.Unmarshal(m.Body.Payload, &payload)
if err2 != nil {
return false
}
return "123" == m.Body.MessageId &&
Expand All @@ -161,9 +161,9 @@ func TestHandler_SendHTTPMessageToClient(t *testing.T) {
require.NoError(t, err)

require.Eventually(t, func() bool {
// ensure all goroutines close
err := handler.Close()
require.NoError(t, err)
// // ensure all goroutines close
err2 := handler.Close()
require.NoError(t, err2)
return httpClient.AssertExpectations(t) && don.AssertExpectations(t)
}, tests.WaitTimeout(t), 100*time.Millisecond)
})
Expand Down

0 comments on commit 27bfa02

Please sign in to comment.