case_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/job/main/credit/model"
  7. xtime "go-common/library/time"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func Test_AddBlockedCase(t *testing.T) {
  11. Convey("should return err be nil", t, func() {
  12. ca := &model.Case{}
  13. ca.Mid = 6660
  14. ca.BlockedDay = 7
  15. err := d.AddBlockedCase(context.TODO(), ca)
  16. So(err, ShouldBeNil)
  17. })
  18. }
  19. func Test_UpGrantCase(t *testing.T) {
  20. Convey("should return err be nil", t, func() {
  21. now := time.Now()
  22. err := d.UpGrantCase(context.TODO(), []int64{1, 2}, xtime.Time(now.Unix()), xtime.Time(now.Unix()))
  23. So(err, ShouldBeNil)
  24. })
  25. }
  26. func Test_Grantcase(t *testing.T) {
  27. Convey("should return err be nil", t, func() {
  28. sc, err := d.Grantcase(context.TODO(), 3)
  29. So(err, ShouldBeNil)
  30. So(sc, ShouldNotBeNil)
  31. So(sc, ShouldResemble, make(map[int64]*model.SimCase))
  32. })
  33. }
  34. func Test_CaseVote(t *testing.T) {
  35. Convey("should return err be nil", t, func() {
  36. cv, err := d.CaseVote(context.TODO(), 1004)
  37. So(err, ShouldBeNil)
  38. So(cv, ShouldNotBeNil)
  39. })
  40. }
  41. func Test_CaseRelationIDCount(t *testing.T) {
  42. Convey("should return err be nil", t, func() {
  43. count, err := d.CaseRelationIDCount(context.TODO(), 2, "2-8-113")
  44. So(err, ShouldBeNil)
  45. So(count, ShouldBeGreaterThanOrEqualTo, 0)
  46. })
  47. }
  48. func Test_CaseVotesCID(t *testing.T) {
  49. Convey("should return err be nil", t, func() {
  50. cv, err := d.CaseVotesCID(context.TODO(), 2)
  51. So(err, ShouldBeNil)
  52. So(cv, ShouldNotBeNil)
  53. })
  54. }
  55. func Test_CountCaseMID(t *testing.T) {
  56. Convey("should return err be nil", t, func() {
  57. count, err := d.CountCaseMID(context.TODO(), 1, 2)
  58. So(err, ShouldBeNil)
  59. So(count, ShouldNotBeNil)
  60. })
  61. }