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

Function TestHTTPStatusCode

assert/http_assertions_test.go:115–139  ·  assert/http_assertions_test.go::TestHTTPStatusCode
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func TestHTTPStatusCode(t *testing.T) {
116 t.Parallel()
117
118 assert := New(t)
119
120 mockT1 := new(testing.T)
121 assert.Equal(HTTPStatusCode(mockT1, httpOK, "GET", "/", nil, http.StatusSwitchingProtocols), false)
122 assert.True(mockT1.Failed())
123
124 mockT2 := new(testing.T)
125 assert.Equal(HTTPStatusCode(mockT2, httpRedirect, "GET", "/", nil, http.StatusSwitchingProtocols), false)
126 assert.True(mockT2.Failed())
127
128 mockT3 := new(mockTestingT)
129 assert.Equal(HTTPStatusCode(
130 mockT3, httpError, "GET", "/", nil, http.StatusSwitchingProtocols,
131 "Expected the status code to be %d", http.StatusSwitchingProtocols,
132 ), false)
133 assert.True(mockT3.Failed())
134 assert.Contains(mockT3.errorString(), "Expected the status code to be 101")
135
136 mockT4 := new(testing.T)
137 assert.Equal(HTTPStatusCode(mockT4, httpStatusCode, "GET", "/", nil, http.StatusSwitchingProtocols), true)
138 assert.False(mockT4.Failed())
139}
140
141func TestHTTPStatusesWrapper(t *testing.T) {
142 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected