Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. 3 строка.
  2. func TestNotification(t *testing.T) {
  3. tt := time.Now().Unix() + 30*60
  4. n := model.NotificationThread{
  5. ChannelID: "1",
  6. UserID: "1",
  7. NotificationTime: tt,
  8. ReminderCounter: 0,
  9. }
  10.  
  11. notification, err := db.CreateNotificationThread(n)
  12. require.NoError(t, err)
  13. assert.Equal(t, "1", notification.ChannelID)
  14. assert.Equal(t, "1", notification.UserID)
  15. assert.Equal(t, tt, notification.NotificationTime)
  16. assert.Equal(t, 0, notification.ReminderCounter)
  17.  
  18. thread, err := db.SelectNotificationsThread(notification.ChannelID)
  19. require.NoError(t, err)
  20. assert.Equal(t, thread.ChannelID, notification.ChannelID)
  21.  
  22. err = db.DeleteNotificationThread(notification.ID)
  23. require.NoError(t, err)
  24.  
  25. thread, err = db.SelectNotificationsThread(notification.ChannelID)
  26. assert.Equal(t, 0, thread.ReminderCounter)
  27. assert.Equal(t, "", thread.UserID)
  28. assert.Equal(t, int64(0), thread.NotificationTime)
  29. assert.Equal(t, "", thread.ChannelID)
  30.  
  31. n = model.NotificationThread{
  32. ChannelID: "1",
  33. UserID: "User1",
  34. NotificationTime: tt,
  35. ReminderCounter: 0,
  36. }
  37.  
  38. nt, err := db.CreateNotificationThread(n)
  39. require.NoError(t, err)
  40.  
  41. err = db.UpdateNotificationThread(nt.ID, nt.ChannelID, tt)
  42. require.NoError(t, err)
  43.  
  44. thread, err = db.SelectNotificationsThread(nt.ChannelID)
  45. require.NoError(t, err)
  46. assert.Equal(t, 1, thread.ReminderCounter)
  47.  
  48. err = db.DeleteNotificationThread(nt.ID)
  49. require.NoError(t, err)
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement