blacklist_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package income
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestIncomeListAvBlackList(t *testing.T) {
  8. convey.Convey("ListAvBlackList", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. avID = []int64{19930812}
  12. ctype = int(0)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. Exec(c, "INSERT INTO av_black_list(av_id, mid) VALUES(19930812,19930812)")
  16. avb, err := d.ListAvBlackList(c, avID, ctype)
  17. ctx.Convey("Then err should be nil.avb should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(avb, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestIncomeGetAvBlackListByMID(t *testing.T) {
  25. convey.Convey("GetAvBlackListByMID", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. mid = int64(19930812)
  29. typ = int(0)
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. Exec(c, "INSERT INTO av_black_list(av_id, mid) VALUES(1002,19930812)")
  33. avb, err := d.GetAvBlackListByMID(c, mid, typ)
  34. ctx.Convey("Then err should be nil.avb should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(avb, convey.ShouldNotBeNil)
  37. })
  38. })
  39. })
  40. }
  41. func TestIncomeTxInsertAvBlackList(t *testing.T) {
  42. convey.Convey("TxInsertAvBlackList", t, func(ctx convey.C) {
  43. var (
  44. tx, _ = d.BeginTran(context.Background())
  45. val = "(1001,1000,0,'test','szy',1,0)"
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. rows, err := d.TxInsertAvBlackList(tx, val)
  49. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. ctx.So(rows, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }