ugift_week_test.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/live/gift/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoGetWeekBagStatus(t *testing.T) {
  9. convey.Convey("GetWeekBagStatus", t, func(c convey.C) {
  10. var (
  11. ctx = context.Background()
  12. uid = int64(0)
  13. week = int(0)
  14. level = int64(0)
  15. )
  16. c.Convey("When everything gose positive", func(c convey.C) {
  17. res, err := d.GetWeekBagStatus(ctx, uid, week, level)
  18. c.Convey("Then err should be nil.res should not be nil.", func(c convey.C) {
  19. c.So(err, convey.ShouldBeNil)
  20. c.So(res, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoAddWeekBag(t *testing.T) {
  26. convey.Convey("AddWeekBag", t, func(c convey.C) {
  27. var (
  28. ctx = context.Background()
  29. uid = int64(9527)
  30. week = int(1)
  31. level = int64(1)
  32. weekInfo = &model.BagGiftStatus{
  33. Status: 1,
  34. Gift: []*model.GiftInfo{
  35. {GiftID: 1, GiftNum: 2, ExpireAt: "7天"}, {GiftID: 2, GiftNum: 3, ExpireAt: "7天"},
  36. },
  37. }
  38. )
  39. c.Convey("When everything gose positive", func(c convey.C) {
  40. affected, err := d.AddWeekBag(ctx, uid, week, level, weekInfo)
  41. c.Convey("Then err should be nil.affected should not be nil.", func(c convey.C) {
  42. c.So(err, convey.ShouldBeNil)
  43. c.So(affected, convey.ShouldNotBeNil)
  44. })
  45. })
  46. })
  47. }