()
| 503 | } |
| 504 | |
| 505 | func (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 | |
| 528 | func (s *MessageSuite) Test_CreateMessage_onFormData() { |
| 529 | auth.RegisterAuthentication(s.ctx, nil, 4, "app-token") |
nothing calls this directly
no test coverage detected