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

Method checkNotType

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

Source from the content-addressed store, hash-verified

261}
262
263func (wm *WebsocketMessage) checkNotType(opChain *chain, types ...int) {
264 if opChain.failed() {
265 return
266 }
267
268 if len(types) == 0 {
269 opChain.fail(AssertionFailure{
270 Type: AssertUsage,
271 Errors: []error{
272 errors.New("missing type argument"),
273 },
274 })
275 return
276 }
277
278 found := false
279 for _, t := range types {
280 if t == wm.typ {
281 found = true
282 break
283 }
284 }
285
286 if found {
287 if len(types) == 1 {
288 opChain.fail(AssertionFailure{
289 Type: AssertNotEqual,
290 Actual: &AssertionValue{wsMessageType(wm.typ)},
291 Expected: &AssertionValue{wsMessageType(types[0])},
292 Errors: []error{
293 errors.New("expected: message types are non-equal"),
294 },
295 })
296 } else {
297 typeList := make([]interface{}, 0, len(types))
298 for _, t := range types {
299 typeList = append(typeList, wsMessageType(t))
300 }
301
302 opChain.fail(AssertionFailure{
303 Type: AssertNotBelongs,
304 Actual: &AssertionValue{wsMessageType(wm.typ)},
305 Expected: &AssertionValue{AssertionList(typeList)},
306 Errors: []error{
307 errors.New("expected: message type does not belong to given list"),
308 },
309 })
310 }
311 }
312}
313
314// Code succeeds if WebSocket close code is one of the given.
315//

Callers 4

NotCloseMessageMethod · 0.95
NotBinaryMessageMethod · 0.95
NotTextMessageMethod · 0.95
NotTypeMethod · 0.95

Calls 4

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

Tested by

no test coverage detected