MCPcopy
hub / github.com/stretchr/testify / TestHTTPError

Function TestHTTPError

assert/http_assertions_test.go:89–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestHTTPError(t *testing.T) {
90 t.Parallel()
91
92 assert := New(t)
93
94 mockT1 := new(testing.T)
95 assert.Equal(HTTPError(mockT1, httpOK, "GET", "/", nil), false)
96 assert.True(mockT1.Failed())
97
98 mockT2 := new(mockTestingT)
99 assert.Equal(HTTPError(
100 mockT2, httpRedirect, "GET", "/", nil,
101 "Expected this request to error out. But it didn't",
102 ), false)
103 assert.True(mockT2.Failed())
104 assert.Contains(mockT2.errorString(), "Expected this request to error out. But it didn't")
105
106 mockT3 := new(testing.T)
107 assert.Equal(HTTPError(mockT3, httpError, "GET", "/", nil), true)
108 assert.False(mockT3.Failed())
109
110 mockT4 := new(testing.T)
111 assert.Equal(HTTPError(mockT4, httpStatusCode, "GET", "/", nil), false)
112 assert.True(mockT4.Failed())
113}
114
115func TestHTTPStatusCode(t *testing.T) {
116 t.Parallel()

Callers

nothing calls this directly

Calls 8

FailedMethod · 0.80
errorStringMethod · 0.80
NewFunction · 0.70
HTTPErrorFunction · 0.70
EqualMethod · 0.45
TrueMethod · 0.45
ContainsMethod · 0.45
FalseMethod · 0.45

Tested by

no test coverage detected