MCPcopy Index your code
hub / github.com/gotify/server / Test_CreateMessage_WithTitle

Method Test_CreateMessage_WithTitle

api/message_test.go:363–382  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

361}
362
363func (s *MessageSuite) Test_CreateMessage_WithTitle() {
364 t, _ := time.Parse("2006/01/02", "2017/01/02")
365 timeNow = func() time.Time { return t }
366 defer func() { timeNow = time.Now }()
367
368 auth.RegisterAuthentication(s.ctx, nil, 4, "app-token")
369 s.db.User(4).AppWithToken(5, "app-token")
370 s.ctx.Request = httptest.NewRequest("POST", "/message", strings.NewReader(`{"title": "mytitle", "message": "mymessage"}`))
371 s.ctx.Request.Header.Set("Content-Type", "application/json")
372
373 s.a.CreateMessage(s.ctx)
374
375 msgs, err := s.db.GetMessagesByApplication(5)
376 assert.NoError(s.T(), err)
377 expected := &model.MessageExternal{ID: 1, ApplicationID: 5, Title: "mytitle", Message: "mymessage", Date: t, Priority: intPtr(0)}
378 assert.Len(s.T(), msgs, 1)
379 assert.Equal(s.T(), expected, toExternalMessage(msgs[0]))
380 assert.Equal(s.T(), 200, s.recorder.Code)
381 assert.Equal(s.T(), expected, s.notifiedMessage)
382}
383
384func (s *MessageSuite) Test_CreateMessage_failWhenNoMessage() {
385 auth.RegisterAuthentication(s.ctx, nil, 4, "app-token")

Callers

nothing calls this directly

Calls 7

RegisterAuthenticationFunction · 0.92
intPtrFunction · 0.85
toExternalMessageFunction · 0.85
AppWithTokenMethod · 0.80
UserMethod · 0.80
CreateMessageMethod · 0.65

Tested by

no test coverage detected