MCPcopy Create free account
hub / github.com/gavv/httpexpect / checkType

Method checkType

websocket_message.go:212–261  ·  view source on GitHub ↗
(opChain *chain, types ...int)

Source from the content-addressed store, hash-verified

210}
211
212func (wm *WebsocketMessage) checkType(opChain *chain, types ...int) {
213 if opChain.failed() {
214 return
215 }
216
217 if len(types) == 0 {
218 opChain.fail(AssertionFailure{
219 Type: AssertUsage,
220 Errors: []error{
221 errors.New("missing type argument"),
222 },
223 })
224 return
225 }
226
227 found := false
228 for _, t := range types {
229 if t == wm.typ {
230 found = true
231 break
232 }
233 }
234
235 if !found {
236 if len(types) == 1 {
237 opChain.fail(AssertionFailure{
238 Type: AssertEqual,
239 Actual: &AssertionValue{wsMessageType(wm.typ)},
240 Expected: &AssertionValue{wsMessageType(types[0])},
241 Errors: []error{
242 errors.New("expected: message types are equal"),
243 },
244 })
245 } else {
246 typeList := make([]interface{}, 0, len(types))
247 for _, t := range types {
248 typeList = append(typeList, wsMessageType(t))
249 }
250
251 opChain.fail(AssertionFailure{
252 Type: AssertBelongs,
253 Actual: &AssertionValue{wsMessageType(wm.typ)},
254 Expected: &AssertionValue{AssertionList(typeList)},
255 Errors: []error{
256 errors.New("expected: message type belongs to given list"),
257 },
258 })
259 }
260 }
261}
262
263func (wm *WebsocketMessage) checkNotType(opChain *chain, types ...int) {
264 if opChain.failed() {

Callers 4

CloseMessageMethod · 0.95
BinaryMessageMethod · 0.95
TextMessageMethod · 0.95
TypeMethod · 0.95

Calls 4

wsMessageTypeTypeAlias · 0.85
AssertionListTypeAlias · 0.85
failedMethod · 0.80
failMethod · 0.80

Tested by

no test coverage detected