cheat_test.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoDelArchiveSpy(t *testing.T) {
  9. convey.Convey("DelArchiveSpy", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. limit = int64(10)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. rows, err := d.DelArchiveSpy(c, limit)
  16. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(rows, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoDelUpSpy(t *testing.T) {
  24. convey.Convey("DelUpSpy", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. limit = int64(100)
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. rows, err := d.DelUpSpy(c, limit)
  31. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(rows, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoAvBreachRecord(t *testing.T) {
  39. convey.Convey("AvBreachRecord", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. id = int64(0)
  43. limit = int64(100)
  44. )
  45. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  46. last, ds, err := d.AvBreachRecord(c, id, limit)
  47. ctx.Convey("Then err should be nil.last,ds should not be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. ctx.So(ds, convey.ShouldNotBeNil)
  50. ctx.So(last, convey.ShouldNotBeNil)
  51. })
  52. })
  53. })
  54. }
  55. func TestDaoUps(t *testing.T) {
  56. convey.Convey("Ups", t, func(ctx convey.C) {
  57. var (
  58. c = context.Background()
  59. mids = []int64{1, 2, 3, 4, 5, 6}
  60. )
  61. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  62. cs, err := d.Ups(c, mids)
  63. ctx.Convey("Then err should be nil.cs should not be nil.", func(ctx convey.C) {
  64. ctx.So(err, convey.ShouldBeNil)
  65. ctx.So(cs, convey.ShouldNotBeNil)
  66. })
  67. })
  68. })
  69. }
  70. func TestDaoAvs(t *testing.T) {
  71. convey.Convey("Avs", t, func(ctx convey.C) {
  72. var (
  73. c = context.Background()
  74. date = time.Now()
  75. aids = []int64{1, 2, 3, 4, 5, 6}
  76. )
  77. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  78. cs, err := d.Avs(c, date, aids)
  79. ctx.Convey("Then err should be nil.cs should not be nil.", func(ctx convey.C) {
  80. ctx.So(err, convey.ShouldBeNil)
  81. ctx.So(cs, convey.ShouldNotBeNil)
  82. })
  83. })
  84. })
  85. }
  86. func TestDaoPlayCount(t *testing.T) {
  87. convey.Convey("PlayCount", t, func(ctx convey.C) {
  88. var (
  89. c = context.Background()
  90. mids = []int64{1, 2, 3, 4, 5, 6}
  91. )
  92. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  93. cs, err := d.PlayCount(c, mids)
  94. ctx.Convey("Then err should be nil.cs should not be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldBeNil)
  96. ctx.So(cs, convey.ShouldNotBeNil)
  97. })
  98. })
  99. })
  100. }
  101. func TestDaoInsertCheatUps(t *testing.T) {
  102. convey.Convey("InsertCheatUps", t, func(ctx convey.C) {
  103. var (
  104. c = context.Background()
  105. values = "(2, '2018-06-23', 'test', 100, 100, 100, 100, 3)"
  106. )
  107. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  108. rows, err := d.InsertCheatUps(c, values)
  109. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  110. ctx.So(err, convey.ShouldNotBeNil)
  111. ctx.So(rows, convey.ShouldNotBeNil)
  112. })
  113. })
  114. })
  115. }
  116. func TestDaoInsertCheatArchives(t *testing.T) {
  117. convey.Convey("InsertCheatArchives", t, func(ctx convey.C) {
  118. var (
  119. c = context.Background()
  120. values = "(1, 2, 'test', '2018-06-23', 100, 100, 100, 100, 100)"
  121. )
  122. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  123. rows, err := d.InsertCheatArchives(c, values)
  124. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  125. ctx.So(err, convey.ShouldBeNil)
  126. ctx.So(rows, convey.ShouldNotBeNil)
  127. })
  128. })
  129. })
  130. }