(opChain *chain, types ...int)
| 210 | } |
| 211 | |
| 212 | func (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 | |
| 263 | func (wm *WebsocketMessage) checkNotType(opChain *chain, types ...int) { |
| 264 | if opChain.failed() { |
no test coverage detected