()
| 317 | } |
| 318 | |
| 319 | func (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 | |
| 341 | func (s *MessageSuite) Test_CreateMessage_WithDefaultPriority() { |
| 342 | t, _ := time.Parse("2006/01/02", "2017/01/02") |
nothing calls this directly
no test coverage detected