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

Function TestHTTPSuccess

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

Source from the content-addressed store, hash-verified

31}
32
33func TestHTTPSuccess(t *testing.T) {
34 t.Parallel()
35
36 assert := New(t)
37
38 mockT1 := new(testing.T)
39 assert.Equal(HTTPSuccess(mockT1, httpOK, "GET", "/", nil), true)
40 assert.False(mockT1.Failed())
41
42 mockT2 := new(testing.T)
43 assert.Equal(HTTPSuccess(mockT2, httpRedirect, "GET", "/", nil), false)
44 assert.True(mockT2.Failed())
45
46 mockT3 := new(mockTestingT)
47 assert.Equal(HTTPSuccess(
48 mockT3, httpError, "GET", "/", nil,
49 "was not expecting a failure here",
50 ), false)
51 assert.True(mockT3.Failed())
52 assert.Contains(mockT3.errorString(), "was not expecting a failure here")
53
54 mockT4 := new(testing.T)
55 assert.Equal(HTTPSuccess(mockT4, httpStatusCode, "GET", "/", nil), false)
56 assert.True(mockT4.Failed())
57
58 mockT5 := new(testing.T)
59 assert.Equal(HTTPSuccess(mockT5, httpReadBody, "POST", "/", nil), true)
60 assert.False(mockT5.Failed())
61}
62
63func TestHTTPRedirect(t *testing.T) {
64 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected