(t *testing.T)
| 526 | } |
| 527 | |
| 528 | func TestRespOnBadHandshake(t *testing.T) { |
| 529 | const expectedStatus = http.StatusGone |
| 530 | const expectedBody = "This is the response body." |
| 531 | |
| 532 | s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 533 | w.WriteHeader(expectedStatus) |
| 534 | io.WriteString(w, expectedBody) |
| 535 | })) |
| 536 | defer s.Close() |
| 537 | |
| 538 | ws, resp, err := cstDialer.Dial(makeWsProto(s.URL), nil) |
| 539 | if err == nil { |
| 540 | ws.Close() |
| 541 | t.Fatalf("Dial: nil") |
| 542 | } |
| 543 | |
| 544 | if resp == nil { |
| 545 | t.Fatalf("resp=nil, err=%v", err) |
| 546 | } |
| 547 | |
| 548 | if resp.StatusCode != expectedStatus { |
| 549 | t.Errorf("resp.StatusCode=%d, want %d", resp.StatusCode, expectedStatus) |
| 550 | } |
| 551 | |
| 552 | p, err := ioutil.ReadAll(resp.Body) |
| 553 | if err != nil { |
| 554 | t.Fatalf("ReadFull(resp.Body) returned error %v", err) |
| 555 | } |
| 556 | |
| 557 | if string(p) != expectedBody { |
| 558 | t.Errorf("resp.Body=%s, want %s", p, expectedBody) |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | type testLogWriter struct { |
| 563 | t *testing.T |
nothing calls this directly
no test coverage detected