MCPcopy Create free account
hub / github.com/gavv/httpexpect / TestBodyWrapper_RewindError

Function TestBodyWrapper_RewindError

body_wrapper_test.go:645–683  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

643}
644
645func TestBodyWrapper_RewindError(t *testing.T) {
646 bodyText := "test_body"
647 body := newMockBody(bodyText)
648
649 body.readErr = errors.New("read_error")
650 body.closeErr = errors.New("close_error")
651
652 wrp := newBodyWrapper(body, nil)
653
654 b := make([]byte, len(bodyText)+1)
655 var err error
656
657 for i := 0; i < 2; i++ {
658 _, err = wrp.Read(b)
659 assert.NotNil(t, err)
660
661 err = wrp.Close()
662 assert.NotNil(t, err)
663
664 _, err = wrp.GetBody()
665 assert.NotNil(t, err)
666 }
667
668 wrp.Rewind()
669
670 body.readErr = nil
671 body.closeErr = nil
672
673 for i := 0; i < 2; i++ {
674 _, err = wrp.Read(b)
675 assert.NotNil(t, err)
676
677 err = wrp.Close()
678 assert.NotNil(t, err)
679
680 _, err = wrp.GetBody()
681 assert.NotNil(t, err)
682 }
683}
684
685func TestBodyWrapper_Memory(t *testing.T) {
686 t.Run("unaligned read", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

newMockBodyFunction · 0.85
newBodyWrapperFunction · 0.85
GetBodyMethod · 0.80
RewindMethod · 0.80
CloseMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…