(t *testing.T)
| 546 | } |
| 547 | |
| 548 | func TestExpect_RequestFactory(t *testing.T) { |
| 549 | t.Run("default factory", func(t *testing.T) { |
| 550 | e := WithConfig(Config{ |
| 551 | BaseURL: "http://example.com", |
| 552 | Reporter: NewAssertReporter(t), |
| 553 | }) |
| 554 | |
| 555 | req := e.Request("GET", "/") |
| 556 | req.chain.assert(t, success) |
| 557 | |
| 558 | assert.NotNil(t, req.httpReq) |
| 559 | }) |
| 560 | |
| 561 | t.Run("custom factory", func(t *testing.T) { |
| 562 | factory := &mockRequestFactory{} |
| 563 | |
| 564 | e := WithConfig(Config{ |
| 565 | BaseURL: "http://example.com", |
| 566 | Reporter: NewAssertReporter(t), |
| 567 | RequestFactory: factory, |
| 568 | }) |
| 569 | |
| 570 | req := e.Request("GET", "/") |
| 571 | req.chain.assert(t, success) |
| 572 | |
| 573 | assert.NotNil(t, factory.lastreq) |
| 574 | assert.Same(t, req.httpReq, factory.lastreq) |
| 575 | }) |
| 576 | |
| 577 | t.Run("factory failure", func(t *testing.T) { |
| 578 | factory := &mockRequestFactory{ |
| 579 | fail: true, |
| 580 | } |
| 581 | |
| 582 | e := WithConfig(Config{ |
| 583 | BaseURL: "http://example.com", |
| 584 | Reporter: newMockReporter(t), |
| 585 | RequestFactory: factory, |
| 586 | }) |
| 587 | |
| 588 | req := e.Request("GET", "/") |
| 589 | req.chain.assert(t, failure) |
| 590 | |
| 591 | assert.Nil(t, factory.lastreq) |
| 592 | }) |
| 593 | } |
| 594 | |
| 595 | func TestExpect_Panics(t *testing.T) { |
| 596 | t.Run("nil AssertionHandler, non-nil Reporter", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…