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

Function TestWebsocketMessage_MatchCodes

websocket_message_test.go:536–590  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

534}
535
536func TestWebsocketMessage_MatchCodes(t *testing.T) {
537 cases := []struct {
538 name string
539 typ int
540 code int
541 testCodes []int
542 wantCode chainResult
543 wantNotCode chainResult
544 }{
545 {
546 name: "close message with close code 10 and with test codes 10 and 20",
547 typ: websocket.CloseMessage,
548 code: 10,
549 testCodes: []int{10, 20},
550 wantCode: success,
551 wantNotCode: failure,
552 },
553 {
554 name: "close message with close code 10 and with test codes 20 and 10",
555 typ: websocket.CloseMessage,
556 code: 10,
557 testCodes: []int{20, 10},
558 wantCode: success,
559 wantNotCode: failure,
560 },
561 {
562 name: "close message with close code 10 and with test codes 30 and 20",
563 typ: websocket.CloseMessage,
564 code: 10,
565 testCodes: []int{30, 20},
566 wantCode: failure,
567 wantNotCode: success,
568 },
569 {
570 name: "close message with close code 10 and with test codes 20 and 30",
571 typ: websocket.CloseMessage,
572 code: 10,
573 testCodes: []int{20, 30},
574 wantCode: failure,
575 wantNotCode: success,
576 },
577 }
578
579 for _, tc := range cases {
580 t.Run(tc.name, func(t *testing.T) {
581 reporter := newMockReporter(t)
582
583 NewWebsocketMessage(reporter, tc.typ, nil, tc.code).Code(tc.testCodes...).
584 chain.assert(t, tc.wantCode)
585
586 NewWebsocketMessage(reporter, tc.typ, nil, tc.code).NotCode(tc.testCodes...).
587 chain.assert(t, tc.wantNotCode)
588 })
589 }
590}
591
592func TestWebsocketMessage_CodeAndType(t *testing.T) {
593 cases := []struct {

Callers

nothing calls this directly

Calls 5

newMockReporterFunction · 0.85
NewWebsocketMessageFunction · 0.85
assertMethod · 0.80
CodeMethod · 0.80
NotCodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…