MCPcopy Index your code
hub / github.com/dnote/dnote / HTTPDo

Function HTTPDo

pkg/server/testutils/main.go:116–132  ·  view source on GitHub ↗

HTTPDo makes an HTTP request and returns a response

(t *testing.T, req *http.Request)

Source from the content-addressed store, hash-verified

114
115// HTTPDo makes an HTTP request and returns a response
116func HTTPDo(t *testing.T, req *http.Request) *http.Response {
117 hc := http.Client{
118 // Do not follow redirects.
119 // e.g. /logout redirects to a page but we'd like to test the redirect
120 // itself, not what happens after the redirect
121 CheckRedirect: func(req *http.Request, via []*http.Request) error {
122 return http.ErrUseLastResponse
123 },
124 }
125
126 res, err := hc.Do(req)
127 if err != nil {
128 t.Fatal(errors.Wrap(err, "performing http request"))
129 }
130
131 return res
132}
133
134// SetReqAuthHeader sets the authorization header in the given request for the given user with a specific DB
135func SetReqAuthHeader(t *testing.T, db *gorm.DB, req *http.Request, user database.User) {

Callers 15

TestGetNoteFunction · 0.92
TestNotSupportedVersionsFunction · 0.92
TestHealthFunction · 0.92
TestJoinFunction · 0.92
TestJoinErrorFunction · 0.92
TestJoinDuplicateEmailFunction · 0.92
TestJoinDisabledFunction · 0.92
TestLoginFunction · 0.92
TestLogoutFunction · 0.92
TestResetPasswordFunction · 0.92
TestCreateResetTokenFunction · 0.92
TestGuestOnlyFunction · 0.92

Calls

no outgoing calls

Tested by 14

TestGetNoteFunction · 0.74
TestNotSupportedVersionsFunction · 0.74
TestHealthFunction · 0.74
TestJoinFunction · 0.74
TestJoinErrorFunction · 0.74
TestJoinDuplicateEmailFunction · 0.74
TestJoinDisabledFunction · 0.74
TestLoginFunction · 0.74
TestLogoutFunction · 0.74
TestResetPasswordFunction · 0.74
TestCreateResetTokenFunction · 0.74
TestGuestOnlyFunction · 0.74