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

Function TestHTTPRedirect

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

Source from the content-addressed store, hash-verified

61}
62
63func TestHTTPRedirect(t *testing.T) {
64 t.Parallel()
65
66 assert := New(t)
67
68 mockT1 := new(mockTestingT)
69 assert.Equal(HTTPRedirect(
70 mockT1, httpOK, "GET", "/", nil,
71 "was expecting a 3xx status code. Got 200.",
72 ), false)
73 assert.True(mockT1.Failed())
74 assert.Contains(mockT1.errorString(), "was expecting a 3xx status code. Got 200.")
75
76 mockT2 := new(testing.T)
77 assert.Equal(HTTPRedirect(mockT2, httpRedirect, "GET", "/", nil), true)
78 assert.False(mockT2.Failed())
79
80 mockT3 := new(testing.T)
81 assert.Equal(HTTPRedirect(mockT3, httpError, "GET", "/", nil), false)
82 assert.True(mockT3.Failed())
83
84 mockT4 := new(testing.T)
85 assert.Equal(HTTPRedirect(mockT4, httpStatusCode, "GET", "/", nil), false)
86 assert.True(mockT4.Failed())
87}
88
89func TestHTTPError(t *testing.T) {
90 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…