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

Function TestWithAccount

pkg/server/middleware/auth_test.go:233–251  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

231}
232
233func TestWithAccount(t *testing.T) {
234 db := testutils.InitMemoryDB(t)
235
236 handler := func(w http.ResponseWriter, r *http.Request) {
237 w.WriteHeader(http.StatusOK)
238 }
239
240 t.Run("authenticated user", func(t *testing.T) {
241 user := testutils.SetupUserData(db, "alice@test.com", "pass1234")
242
243 server := httptest.NewServer(Auth(db, handler, nil))
244 defer server.Close()
245
246 req := testutils.MakeReq(server.URL, "GET", "/", "")
247 res := testutils.HTTPAuthDo(t, db, req, user)
248
249 assert.Equal(t, res.StatusCode, http.StatusOK, "status code mismatch")
250 })
251}

Callers

nothing calls this directly

Calls 8

InitMemoryDBFunction · 0.92
SetupUserDataFunction · 0.92
MakeReqFunction · 0.92
HTTPAuthDoFunction · 0.92
EqualFunction · 0.92
AuthFunction · 0.85
WriteHeaderMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected