ugift_day_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 TestDaoGetDayBagStatus(t *testing.T) {
  9. convey.Convey("GetDayBagStatus", t, func(c convey.C) {
  10. var (
  11. ctx = context.Background()
  12. uid = int64(0)
  13. date = ""
  14. )
  15. c.Convey("When everything gose positive", func(c convey.C) {
  16. res, err := d.GetDayBagStatus(ctx, uid, date)
  17. c.Convey("Then err should be nil.res should not be nil.", func(c convey.C) {
  18. c.So(err, convey.ShouldBeNil)
  19. c.So(res, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoAddDayBag(t *testing.T) {
  25. convey.Convey("AddDayBag", t, func(c convey.C) {
  26. var (
  27. ctx = context.Background()
  28. uid = int64(9527)
  29. date = "2018-07-04 00:00:00"
  30. dayInfo = &model.BagGiftStatus{
  31. Status: 1,
  32. Gift: []*model.GiftInfo{
  33. {GiftID: 1, GiftNum: 2, ExpireAt: "今天"}, {GiftID: 2, GiftNum: 3, ExpireAt: "今天"},
  34. },
  35. }
  36. )
  37. c.Convey("When everything gose positive", func(c convey.C) {
  38. affected, err := d.AddDayBag(ctx, uid, date, dayInfo)
  39. c.Convey("Then err should be nil.affected should not be nil.", func(c convey.C) {
  40. c.So(err, convey.ShouldBeNil)
  41. c.So(affected, convey.ShouldNotBeNil)
  42. })
  43. })
  44. })
  45. }