mysql_test.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/passport-game/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaohit(t *testing.T) {
  9. var (
  10. mid = int64(1)
  11. )
  12. convey.Convey("hit", t, func(ctx convey.C) {
  13. p1 := hit(mid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoMemberInfo(t *testing.T) {
  20. var (
  21. c = context.TODO()
  22. mid = int64(1)
  23. )
  24. convey.Convey("MemberInfo", t, func(ctx convey.C) {
  25. res, err := d.MemberInfo(c, mid)
  26. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  27. ctx.So(err, convey.ShouldBeNil)
  28. ctx.So(res, convey.ShouldBeNil)
  29. })
  30. })
  31. }
  32. func TestDaoApps(t *testing.T) {
  33. var (
  34. c = context.TODO()
  35. )
  36. convey.Convey("Apps", t, func(ctx convey.C) {
  37. res, err := d.Apps(c)
  38. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldBeNil)
  40. ctx.So(res, convey.ShouldNotBeNil)
  41. })
  42. })
  43. }
  44. func TestDaoAddToken(t *testing.T) {
  45. var (
  46. c = context.TODO()
  47. no = &model.Perm{}
  48. )
  49. convey.Convey("AddToken", t, func(ctx convey.C) {
  50. affected, err := d.AddToken(c, no)
  51. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  52. ctx.So(err, convey.ShouldNotBeNil)
  53. ctx.So(affected, convey.ShouldNotBeNil)
  54. })
  55. })
  56. }
  57. func TestDaoUpdateToken(t *testing.T) {
  58. var (
  59. c = context.TODO()
  60. no = &model.Perm{}
  61. )
  62. convey.Convey("UpdateToken", t, func(ctx convey.C) {
  63. affected, err := d.UpdateToken(c, no)
  64. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldBeNil)
  66. ctx.So(affected, convey.ShouldNotBeNil)
  67. })
  68. })
  69. }
  70. func TestDaoToken(t *testing.T) {
  71. var (
  72. c = context.TODO()
  73. accessToken = "123456"
  74. )
  75. convey.Convey("Token", t, func(ctx convey.C) {
  76. res, err := d.Token(c, accessToken)
  77. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. ctx.So(res, convey.ShouldBeNil)
  80. })
  81. })
  82. }
  83. func TestDaoAsoAccount(t *testing.T) {
  84. var (
  85. c = context.TODO()
  86. identify = "123456"
  87. identifyHash = "654321"
  88. )
  89. convey.Convey("AsoAccount", t, func(ctx convey.C) {
  90. res, err := d.AsoAccount(c, identify, identifyHash)
  91. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  92. ctx.So(err, convey.ShouldBeNil)
  93. ctx.So(res, convey.ShouldBeNil)
  94. })
  95. })
  96. }
  97. func TestDaoAccountInfo(t *testing.T) {
  98. var (
  99. c = context.TODO()
  100. mid = int64(1)
  101. )
  102. convey.Convey("AccountInfo", t, func(ctx convey.C) {
  103. res, err := d.AccountInfo(c, mid)
  104. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  105. ctx.So(err, convey.ShouldBeNil)
  106. ctx.So(res, convey.ShouldNotBeNil)
  107. })
  108. })
  109. }
  110. func TestDaoTokenFromOtherRegion(t *testing.T) {
  111. var (
  112. c = context.TODO()
  113. accessToken = "123456"
  114. )
  115. convey.Convey("TokenFromOtherRegion", t, func(ctx convey.C) {
  116. res, err := d.TokenFromOtherRegion(c, accessToken)
  117. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  118. ctx.So(err, convey.ShouldBeNil)
  119. ctx.So(res, convey.ShouldBeNil)
  120. })
  121. })
  122. }