MCPcopy
hub / github.com/coder/websocket / testAllMessagesReceived

Function testAllMessagesReceived

internal/examples/chat/chat_test.go:139–154  ·  view source on GitHub ↗

testAllMessagesReceived ensures that after n reads, all msgs in msgs have been read.

(cl *client, n int, msgs map[string]struct{})

Source from the content-addressed store, hash-verified

137// testAllMessagesReceived ensures that after n reads, all msgs in msgs
138// have been read.
139func testAllMessagesReceived(cl *client, n int, msgs map[string]struct{}) error {
140 msgs = cloneMessages(msgs)
141
142 for i := 0; i < n; i++ {
143 msg, err := cl.nextMessage()
144 if err != nil {
145 return err
146 }
147 delete(msgs, msg)
148 }
149
150 if len(msgs) != 0 {
151 return fmt.Errorf("did not receive all expected messages: %q", msgs)
152 }
153 return nil
154}
155
156func cloneMessages(msgs map[string]struct{}) map[string]struct{} {
157 msgs2 := make(map[string]struct{}, len(msgs))

Callers 1

Test_chatServerFunction · 0.85

Calls 2

cloneMessagesFunction · 0.85
nextMessageMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…