likes_test.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "net"
  6. "testing"
  7. "go-common/app/admin/main/activity/model"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaoimgAddKey(t *testing.T) {
  11. convey.Convey("imgAddKey", t, func(ctx convey.C) {
  12. var (
  13. uri = "http://i2.hdslb.com/bfs/face/5d2c92beb774a4bb30762538bb102d23670ae9c0.gif"
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. url := imgAddKey(uri)
  17. ctx.Convey("Then url should not be nil.", func(ctx convey.C) {
  18. ctx.So(url, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoGetLikeContent(t *testing.T) {
  24. convey.Convey("GetLikeContent", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. ids = []int64{1, 2}
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. outRes, err := d.GetLikeContent(c, ids)
  31. ctx.Convey("Then err should be nil.outRes should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. fmt.Printf("%+v", outRes)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoActSubject(t *testing.T) {
  39. convey.Convey("ActSubject", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. sid = int64(10256)
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. rp, err := d.ActSubject(c, sid)
  46. ctx.Convey("Then err should be nil.rp should not be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. fmt.Printf("%+v", rp)
  49. })
  50. })
  51. })
  52. }
  53. func TestDaoMusics(t *testing.T) {
  54. convey.Convey("Musics", t, func(ctx convey.C) {
  55. var (
  56. c = context.Background()
  57. aids = []int64{1, 2}
  58. ip = "10.248.25.36"
  59. )
  60. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  61. music, err := d.Musics(c, aids, ip)
  62. ctx.Convey("Then err should be nil.music should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. fmt.Printf("%+v", music)
  65. })
  66. })
  67. })
  68. }
  69. func TestDaoBatchLike(t *testing.T) {
  70. convey.Convey("BatchLike", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. item = &model.Like{Sid: 10256, Mid: 55}
  74. wids = []int64{}
  75. ipv6 = net.ParseIP("192.168.3.32")
  76. )
  77. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  78. err := d.BatchLike(c, item, wids, ipv6)
  79. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  80. ctx.So(err, convey.ShouldBeNil)
  81. })
  82. })
  83. })
  84. }