mc_test.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/job/main/passport-sns/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDao_snsKey(t *testing.T) {
  9. convey.Convey("snsKey", t, func(ctx convey.C) {
  10. var (
  11. platform = model.PlatformQQStr
  12. mid = int64(0)
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. res := snsKey(platform, mid)
  16. ctx.Convey("Then res should not be nil.", func(ctx convey.C) {
  17. ctx.So(res, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDao_SetSnsCache(t *testing.T) {
  23. convey.Convey("SetSnsCache", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. mid = int64(0)
  27. platform = model.PlatformQQStr
  28. qq = &model.SnsProto{}
  29. )
  30. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  31. err := d.SetSnsCache(c, mid, platform, qq)
  32. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDao_DelSnsCache(t *testing.T) {
  39. convey.Convey("DelSnsCache", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. mid = int64(0)
  43. platform = model.PlatformQQStr
  44. )
  45. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  46. err := d.DelSnsCache(c, mid, platform)
  47. ctx.Convey("Then err should be nil.info should not be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestDao_GetUnionIDCache(t *testing.T) {
  54. convey.Convey("GetUnionIDCache", t, func(ctx convey.C) {
  55. var (
  56. c = context.Background()
  57. key = "test"
  58. )
  59. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  60. res, err := d.GetUnionIDCache(c, key)
  61. ctx.Convey("Then err should be nil.res should be nil.", func(ctx convey.C) {
  62. ctx.So(res, convey.ShouldBeEmpty)
  63. ctx.So(err, convey.ShouldBeNil)
  64. })
  65. })
  66. })
  67. }