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

Function TestJoinDisabled

pkg/server/controllers/users_test.go:236–262  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func TestJoinDisabled(t *testing.T) {
237 db := testutils.InitMemoryDB(t)
238
239 // Setup
240 a := app.NewTest()
241 a.Clock = clock.NewMock()
242 a.DB = db
243 a.DisableRegistration = true
244 server := MustNewServer(t, &a)
245 defer server.Close()
246
247 dat := url.Values{}
248 dat.Set("email", "alice@example.com")
249 dat.Set("password", "foobarbaz")
250 req := testutils.MakeFormReq(server.URL, "POST", "/join", dat)
251
252 // Execute
253 res := testutils.HTTPDo(t, req)
254
255 // Test
256 assert.StatusCodeEquals(t, res, http.StatusNotFound, "status code mismatch")
257
258 var userCount int64
259 testutils.MustExec(t, db.Model(&database.User{}).Count(&userCount), "counting user")
260
261 assert.Equal(t, userCount, int64(0), "user count mismatch")
262}
263
264func TestLogin(t *testing.T) {
265 testutils.RunForWebAndAPI(t, "success", func(t *testing.T, target testutils.EndpointType) {

Callers

nothing calls this directly

Calls 10

InitMemoryDBFunction · 0.92
NewTestFunction · 0.92
NewMockFunction · 0.92
MakeFormReqFunction · 0.92
HTTPDoFunction · 0.92
StatusCodeEqualsFunction · 0.92
MustExecFunction · 0.92
EqualFunction · 0.92
MustNewServerFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected