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

Method Test_CreateMessage_onQueryData

api/message_test.go:505–526  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

503}
504
505func (s *MessageSuite) Test_CreateMessage_onQueryData() {
506 auth.RegisterAuthentication(s.ctx, nil, 4, "app-token")
507 s.db.User(4).AppWithToken(2, "app-token")
508
509 t, _ := time.Parse("2006/01/02", "2017/01/02")
510 timeNow = func() time.Time { return t }
511 defer func() { timeNow = time.Now }()
512
513 s.ctx.Request = httptest.NewRequest("POST", "/message?title=mytitle&message=mymessage&priority=1", nil)
514 s.ctx.Request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
515
516 s.a.CreateMessage(s.ctx)
517
518 expected := &model.MessageExternal{ID: 1, ApplicationID: 2, Title: "mytitle", Message: "mymessage", Priority: intPtr(1), Date: t}
519
520 msgs, err := s.db.GetMessagesByApplication(2)
521 assert.NoError(s.T(), err)
522 assert.Len(s.T(), msgs, 1)
523 assert.Equal(s.T(), expected, toExternalMessage(msgs[0]))
524 assert.Equal(s.T(), 200, s.recorder.Code)
525 assert.Equal(s.T(), uint(1), s.notifiedMessage.ID)
526}
527
528func (s *MessageSuite) Test_CreateMessage_onFormData() {
529 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