mysql_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/dm/model"
  6. )
  7. func TestSubject(t *testing.T) {
  8. var (
  9. c = context.TODO()
  10. tp int32 = 1
  11. oid int64 = 1221
  12. )
  13. s, err := testDao.Subject(c, tp, oid)
  14. if err != nil {
  15. t.Error(err)
  16. }
  17. if s == nil {
  18. t.Logf("oid:%d subject not exist", oid)
  19. } else {
  20. t.Logf("subject:%+v", s)
  21. }
  22. }
  23. func TestIndex(t *testing.T) {
  24. var (
  25. c = context.TODO()
  26. tp int32 = 1
  27. oid int64 = 1221
  28. dmid int64 = 719150137
  29. )
  30. dm, err := testDao.Index(c, tp, oid, dmid)
  31. if err != nil {
  32. t.Error(err)
  33. }
  34. if dm == nil {
  35. t.Logf("dmid:%d not exist", dmid)
  36. } else {
  37. t.Logf("dm:%+v", dm)
  38. }
  39. }
  40. func TestIndexsByID(t *testing.T) {
  41. var (
  42. c = context.TODO()
  43. tp int32 = 1
  44. oid int64 = 1221
  45. dmids = []int64{719150137, 719150230, 719150141}
  46. )
  47. res, special, err := testDao.IndexsByID(c, tp, oid, dmids)
  48. if err != nil {
  49. t.Error(err)
  50. }
  51. for _, dm := range res {
  52. t.Logf("dm:%+v", dm)
  53. }
  54. t.Logf("special:%+v", special)
  55. }
  56. func TestContent(t *testing.T) {
  57. var (
  58. c = context.TODO()
  59. oid int64 = 1221
  60. dmid int64 = 719150137
  61. )
  62. ct, err := testDao.Content(c, oid, dmid)
  63. if err != nil {
  64. t.Error(err)
  65. }
  66. if ct == nil {
  67. t.Logf("content:%d not exist", dmid)
  68. } else {
  69. t.Logf("content:%+v", ct)
  70. }
  71. }
  72. func TestContents(t *testing.T) {
  73. var (
  74. c = context.TODO()
  75. oid int64 = 1221
  76. dmids = []int64{719150137, 719150230, 719150141}
  77. )
  78. res, err := testDao.Contents(c, oid, dmids)
  79. if err != nil {
  80. t.Error(err)
  81. }
  82. for _, ct := range res {
  83. t.Logf("content:%+v", ct)
  84. }
  85. }
  86. func TestContentSpecial(t *testing.T) {
  87. var (
  88. c = context.TODO()
  89. dmid int64 = 719150141
  90. )
  91. cs, err := testDao.ContentSpecial(c, dmid)
  92. if err != nil {
  93. t.Error(err)
  94. }
  95. t.Logf("content special:%+v", cs)
  96. }
  97. func TestContentsSpecial(t *testing.T) {
  98. var (
  99. c = context.TODO()
  100. dmids = []int64{719150141, 719150141}
  101. )
  102. res, err := testDao.ContentsSpecial(c, dmids)
  103. if err != nil {
  104. t.Error(err)
  105. }
  106. for _, cs := range res {
  107. t.Logf("content special:%+v", cs)
  108. }
  109. }
  110. func TestCheckTransferJob(t *testing.T) {
  111. var (
  112. from, to int64 = 10108765, 10108763
  113. )
  114. job, err := testDao.CheckTransferJob(context.TODO(), from, to)
  115. if err != nil {
  116. t.Fatal(err)
  117. }
  118. t.Log(job)
  119. }
  120. func TestAddTransferJob(t *testing.T) {
  121. var (
  122. from, to, mid int64 = 10108765, 10108763, 27515615
  123. offset = 1.00
  124. state = model.TransferJobStatInit
  125. )
  126. _, err := testDao.AddTransferJob(context.TODO(), from, to, mid, offset, state)
  127. if err != nil {
  128. t.Fatal(err)
  129. }
  130. }