()
| 339 | } |
| 340 | |
| 341 | func (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 | |
| 363 | func (s *MessageSuite) Test_CreateMessage_WithTitle() { |
| 364 | t, _ := time.Parse("2006/01/02", "2017/01/02") |
nothing calls this directly
no test coverage detected