Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
Return raw response on ReceivePush
Browse files Browse the repository at this point in the history
To match Request behaviour so we can also build a NewExpectError
  • Loading branch information
CaioIcy committed Mar 30, 2021
1 parent ecf874f commit c52834a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions bot/pitaya_client.go
Expand Up @@ -164,20 +164,20 @@ func (c *PClient) Notify(route string, data []byte) error {
}

// ReceivePush ...
func (c *PClient) ReceivePush(route string, timeout int) (Response, error) {
func (c *PClient) ReceivePush(route string, timeout int) (Response, []byte, error) {
ch := c.getPushChannelForRoute(route)

select {
case data := <-ch:
var ret Response
if err := json.Unmarshal(data, &ret); err != nil {
err = fmt.Errorf("Error unmarshaling response: %s", err)
return nil, err
return nil, nil, err
}

return ret, nil
return ret, data, nil
case <-time.After(time.Duration(timeout) * time.Millisecond):
return nil, fmt.Errorf("Timeout waiting for push on route %s", route)
return nil, nil, fmt.Errorf("Timeout waiting for push on route %s", route)
}
}

Expand Down
4 changes: 2 additions & 2 deletions bot/sequential.go
Expand Up @@ -171,15 +171,15 @@ func (b *SequentialBot) runFunction(op *models.Operation) error {

func (b *SequentialBot) listenToPush(op *models.Operation) error {
b.logger.Debug("Waiting for push on route: " + op.URI)
resp, err := b.client.ReceivePush(op.URI, op.Timeout)
resp, rawResp, err := b.client.ReceivePush(op.URI, op.Timeout)
if err != nil {
return err
}

b.logger.Debug("validating expectations")
err = validateExpectations(op.Expect, resp, b.storage)
if err != nil {
return err
return NewExpectError(err, rawResp, op.Expect)
}
b.logger.Debug("received valid response")

Expand Down

0 comments on commit c52834a

Please sign in to comment.