MCPcopy
hub / github.com/gotify/server / Test_CreateUser_NotifyFail

Method Test_CreateUser_NotifyFail

api/user_test.go:268–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

266}
267
268func (s *UserSuite) Test_CreateUser_NotifyFail() {
269 s.loginAdmin()
270
271 s.notifier.OnUserAdded(func(id uint) error {
272 user, err := s.db.GetUserByID(id)
273 if err != nil {
274 return err
275 }
276 if user.Name == "eva" {
277 return errors.New("some error")
278 }
279 return nil
280 })
281 s.ctx.Request = httptest.NewRequest("POST", "/user", strings.NewReader(`{"name": "eva", "pass": "mylittlepony", "admin": true}`))
282 s.ctx.Request.Header.Set("Content-Type", "application/json")
283
284 s.a.CreateUser(s.ctx)
285
286 assert.Equal(s.T(), 500, s.recorder.Code)
287}
288
289func (s *UserSuite) Test_CreateUser_NoPassword() {
290 s.loginAdmin()

Callers

nothing calls this directly

Calls 4

loginAdminMethod · 0.95
OnUserAddedMethod · 0.80
GetUserByIDMethod · 0.65
CreateUserMethod · 0.65

Tested by

no test coverage detected