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

Method Test_CreateMessage_onJson_allParams

api/message_test.go:319–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

317}
318
319func (s *MessageSuite) Test_CreateMessage_onJson_allParams() {
320 t, _ := time.Parse("2006/01/02", "2017/01/02")
321
322 timeNow = func() time.Time { return t }
323 defer func() { timeNow = time.Now }()
324
325 auth.RegisterAuthentication(s.ctx, nil, 4, "app-token")
326 s.db.User(4).AppWithToken(7, "app-token")
327 s.ctx.Request = httptest.NewRequest("POST", "/message", strings.NewReader(`{"title": "mytitle", "message": "mymessage", "priority": 1}`))
328 s.ctx.Request.Header.Set("Content-Type", "application/json")
329
330 s.a.CreateMessage(s.ctx)
331
332 msgs, err := s.db.GetMessagesByApplication(7)
333 assert.NoError(s.T(), err)
334 expected := &model.MessageExternal{ID: 1, ApplicationID: 7, Title: "mytitle", Message: "mymessage", Priority: intPtr(1), Date: t}
335 assert.Len(s.T(), msgs, 1)
336 assert.Equal(s.T(), expected, toExternalMessage(msgs[0]))
337 assert.Equal(s.T(), 200, s.recorder.Code)
338 assert.Equal(s.T(), expected, s.notifiedMessage)
339}
340
341func (s *MessageSuite) Test_CreateMessage_WithDefaultPriority() {
342 t, _ := time.Parse("2006/01/02", "2017/01/02")

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