mc.cache_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package notice
  2. import (
  3. "context"
  4. "go-common/app/service/live/xuserex/model/roomNotice"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. // TestRoomNoticeAddCacheMonthConsume test.
  9. func TestRoomNoticeAddCacheMonthConsume(t *testing.T) {
  10. convey.Convey("AddCacheMonthConsume", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. id = int64(10000)
  14. targetID = int64(1008)
  15. date = "20190101"
  16. value = &roomNotice.MonthConsume{
  17. Uid: id,
  18. Ruid: targetID,
  19. Amount: 10,
  20. Date: -1,
  21. }
  22. )
  23. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  24. err := d.AddCacheMonthConsume(c, id, targetID, date, value)
  25. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  26. ctx.So(err, convey.ShouldBeNil)
  27. })
  28. })
  29. })
  30. }
  31. // TestRoomNoticeCacheMonthConsume auto test.
  32. func TestRoomNoticeCacheMonthConsume(t *testing.T) {
  33. convey.Convey("CacheMonthConsume", t, func(ctx convey.C) {
  34. var (
  35. c = context.Background()
  36. id = int64(10000)
  37. targetID = int64(1008)
  38. date = "20190101"
  39. )
  40. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  41. res, err := d.CacheMonthConsume(c, id, targetID, date)
  42. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. ctx.So(res, convey.ShouldNotBeNil)
  45. })
  46. })
  47. })
  48. }