GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.4 KiB

  1. package log_test
  2. import (
  3. "testing"
  4. "time"
  5. "git.aiterp.net/rpdata/api/internal/store"
  6. "git.aiterp.net/rpdata/api/model/log"
  7. )
  8. func TestMakeLogID(t *testing.T) {
  9. table := []struct {
  10. Date time.Time
  11. Channel string
  12. Expected string
  13. }{
  14. {
  15. time.Date(2018, 4, 9, 9, 3, 0, 133000000, time.FixedZone("CEST", 7200)), "#Miner'sRespite",
  16. "2018-04-09_070300133_Miner'sRespite",
  17. },
  18. {
  19. time.Date(2017, 3, 23, 23, 59, 59, 0, time.UTC), "#RedrockAgency",
  20. "2017-03-23_235959000_RedrockAgency",
  21. },
  22. }
  23. for _, row := range table {
  24. t.Run(row.Expected, func(t *testing.T) {
  25. id := log.MakeLogID(row.Date, row.Channel)
  26. if id != row.Expected {
  27. t.Error("Failed to make ID, result:", id)
  28. }
  29. })
  30. }
  31. }
  32. func TestSearch(t *testing.T) {
  33. store.Init()
  34. logs, err := log.ListSearch("", nil, []string{"C31", "C51"}, nil, false, 0)
  35. if err != nil {
  36. t.Log(err)
  37. t.Skip()
  38. }
  39. for _, l := range logs {
  40. t.Log(l.ID)
  41. }
  42. }
  43. func TestMovePost(t *testing.T) {
  44. store.Init()
  45. l, err := log.FindID("L684")
  46. if err != nil {
  47. t.Log(err)
  48. t.Skip()
  49. }
  50. posts, err := l.Posts()
  51. if err != nil {
  52. t.Log(err)
  53. t.Skip()
  54. }
  55. for _, post := range posts {
  56. if post.ID == "blfn5uaxpyf11j4phxo" {
  57. start := time.Now()
  58. err := post.Move(1)
  59. if err != nil {
  60. t.Error(err)
  61. }
  62. t.Log(time.Since(start))
  63. }
  64. }
  65. }
  66. func TestMakePostID(t *testing.T) {
  67. t.Log(log.MakePostID(time.Now()))
  68. }