mysql_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/job/main/passport/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDao_AddLoginLog(t *testing.T) {
  10. vs := make([]*model.LoginLog, 0)
  11. v := &model.LoginLog{
  12. Mid: 10,
  13. LoginIP: InetAtoN("127.0.0.1"),
  14. Timestamp: time.Now().Unix(),
  15. Type: 1,
  16. Server: "server",
  17. }
  18. for i := 0; i < 10; i++ {
  19. vs = append(vs, v)
  20. }
  21. if err := d.AddLoginLog(vs); err != nil {
  22. t.Errorf("dao.AddLoginLog(%v) error(%v)", vs, err)
  23. t.FailNow()
  24. }
  25. }
  26. func TestDao_QueryTelBindLog(t *testing.T) {
  27. convey.Convey("", t, func() {
  28. res, err := d.QueryTelBindLog(1)
  29. convey.So(err, convey.ShouldBeNil)
  30. convey.So(res, convey.ShouldNotBeNil)
  31. convey.So(res.ID, convey.ShouldEqual, 1)
  32. })
  33. }
  34. func TestDao_QueryEmailBindLog(t *testing.T) {
  35. convey.Convey("", t, func() {
  36. res, err := d.QueryEmailBindLog(1)
  37. convey.So(err, convey.ShouldBeNil)
  38. convey.So(res, convey.ShouldNotBeNil)
  39. convey.So(res.ID, convey.ShouldEqual, 1)
  40. })
  41. }
  42. func TestDao_BatchGetPwdLog(t *testing.T) {
  43. convey.Convey("BatchGetPwdLog", t, func() {
  44. var (
  45. c = context.Background()
  46. )
  47. res, err := d.BatchGetPwdLog(c, 100000000)
  48. convey.So(err, convey.ShouldBeNil)
  49. convey.So(res, convey.ShouldNotBeNil)
  50. })
  51. }
  52. func TestDao_GetPwdLog(t *testing.T) {
  53. convey.Convey("GetPwdLog", t, func() {
  54. var (
  55. c = context.Background()
  56. )
  57. res, err := d.GetPwdLog(c, 1)
  58. convey.So(err, convey.ShouldBeNil)
  59. convey.So(res, convey.ShouldNotBeNil)
  60. })
  61. }