(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func Test_parseClosePayload(t *testing.T) { |
| 73 | t.Parallel() |
| 74 | |
| 75 | testCases := []struct { |
| 76 | name string |
| 77 | p []byte |
| 78 | success bool |
| 79 | ce CloseError |
| 80 | }{ |
| 81 | { |
| 82 | name: "normal", |
| 83 | p: append([]byte{0x3, 0xE8}, []byte("hello")...), |
| 84 | success: true, |
| 85 | ce: CloseError{ |
| 86 | Code: StatusNormalClosure, |
| 87 | Reason: "hello", |
| 88 | }, |
| 89 | }, |
| 90 | { |
| 91 | name: "nothing", |
| 92 | success: true, |
| 93 | ce: CloseError{ |
| 94 | Code: StatusNoStatusRcvd, |
| 95 | }, |
| 96 | }, |
| 97 | { |
| 98 | name: "oneByte", |
| 99 | p: []byte{0}, |
| 100 | success: false, |
| 101 | }, |
| 102 | { |
| 103 | name: "badStatusCode", |
| 104 | p: []byte{0x17, 0x70}, |
| 105 | success: false, |
| 106 | }, |
| 107 | } |
| 108 | |
| 109 | for _, tc := range testCases { |
| 110 | tc := tc |
| 111 | t.Run(tc.name, func(t *testing.T) { |
| 112 | t.Parallel() |
| 113 | |
| 114 | ce, err := parseClosePayload(tc.p) |
| 115 | if tc.success { |
| 116 | assert.Success(t, err) |
| 117 | assert.Equal(t, "close payload", tc.ce, ce) |
| 118 | } else { |
| 119 | assert.Error(t, err) |
| 120 | } |
| 121 | }) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func Test_validWireCloseCode(t *testing.T) { |
| 126 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…