()
| 361 | } |
| 362 | |
| 363 | func (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 | |
| 384 | func (s *MessageSuite) Test_CreateMessage_failWhenNoMessage() { |
| 385 | auth.RegisterAuthentication(s.ctx, nil, 4, "app-token") |
nothing calls this directly
no test coverage detected