diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2018-03-23 14:28:41 +0100 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2018-03-23 14:28:41 +0100 |
commit | 40cdb18263ac2624c5a007ef1b0ac7d1b21974bd (patch) | |
tree | 2b793bc89d94ab5ebeb43a0bc5f81082583d7c69 /adapter | |
parent | 454ee4bc97c45298e7979f5e3427f7870a628e74 (diff) |
Support mocking reply for more multi requests at once
Change-Id: I3610fe1e0c04f4487f6b7139fc62ef4515fad640
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'adapter')
-rw-r--r-- | adapter/mock/mock_adapter.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/adapter/mock/mock_adapter.go b/adapter/mock/mock_adapter.go index 0b2e8d5..dab51a6 100644 --- a/adapter/mock/mock_adapter.go +++ b/adapter/mock/mock_adapter.go @@ -30,10 +30,10 @@ import ( "github.com/lunixbochs/struc" ) -type ReplyMode int +type replyMode int const ( - _ ReplyMode = 0 + _ replyMode = 0 useRepliesQueue = 1 // use replies in the queue useReplyHandlers = 2 // use reply handler ) @@ -51,7 +51,7 @@ type VppAdapter struct { replies []api.Message // FIFO queue of messages replyHandlers []ReplyHandler // callbacks that are able to calculate mock responses repliesLock sync.Mutex // mutex for the queue - mode ReplyMode // mode in which the mock operates + mode replyMode // mode in which the mock operates } // defaultReply is a default reply message that mock adapter returns for a request. @@ -250,8 +250,7 @@ func (a *VppAdapter) SendMsg(clientID uint32, data []byte) error { for i, reply := range a.replies { if i > 0 && reply.GetMessageName() == "control_ping_reply" { // hack - do not send control_ping_reply immediately, leave it for the the next callback - a.replies = []api.Message{} - a.replies = append(a.replies, reply) + a.replies = a.replies[i:] return nil } msgID, _ := a.GetMsgID(reply.GetMessageName(), reply.GetCrcString()) |