MCPcopy Index your code
hub / github.com/gavv/httpexpect / TestExpect_RequestFactory

Function TestExpect_RequestFactory

expect_test.go:548–593  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

546}
547
548func 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
595func TestExpect_Panics(t *testing.T) {
596 t.Run("nil AssertionHandler, non-nil Reporter", func(t *testing.T) {

Callers

nothing calls this directly

Calls 5

WithConfigFunction · 0.85
NewAssertReporterFunction · 0.85
newMockReporterFunction · 0.85
assertMethod · 0.80
RequestMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…