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

Method Test_CreateMessage_WithDefaultPriority

api/message_test.go:341–361  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

339}
340
341func (s *MessageSuite) Test_CreateMessage_WithDefaultPriority() {
342 t, _ := time.Parse("2006/01/02", "2017/01/02")
343
344 timeNow = func() time.Time { return t }
345 defer func() { timeNow = time.Now }()
346
347 auth.RegisterAuthentication(s.ctx, nil, 4, "app-token")
348 s.db.User(4).AppWithTokenAndDefaultPriority(8, "app-token", 5)
349 s.ctx.Request = httptest.NewRequest("POST", "/message", strings.NewReader(`{"title": "mytitle", "message": "mymessage"}`))
350 s.ctx.Request.Header.Set("Content-Type", "application/json")
351
352 s.a.CreateMessage(s.ctx)
353
354 msgs, err := s.db.GetMessagesByApplication(8)
355 assert.NoError(s.T(), err)
356 expected := &model.MessageExternal{ID: 1, ApplicationID: 8, Title: "mytitle", Message: "mymessage", Priority: intPtr(5), Date: t}
357 assert.Len(s.T(), msgs, 1)
358 assert.Equal(s.T(), expected, toExternalMessage(msgs[0]))
359 assert.Equal(s.T(), 200, s.recorder.Code)
360 assert.Equal(s.T(), expected, s.notifiedMessage)
361}
362
363func (s *MessageSuite) Test_CreateMessage_WithTitle() {
364 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
UserMethod · 0.80
CreateMessageMethod · 0.65

Tested by

no test coverage detected