block_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/growup/model"
  7. xtime "go-common/library/time"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func Test_BlockSql(t *testing.T) {
  11. Convey("query apply_at from up_info_video by mid", t, WithMysql(func(d *Dao) {
  12. mid := int64(1011)
  13. _, err := d.ApplyAt(context.Background(), mid)
  14. So(err, ShouldBeNil)
  15. }))
  16. Convey("insert block up to blacklist", t, WithMysql(func(d *Dao) {
  17. v := &model.Blocked{MID: int64(1011), Nickname: "hello", OriginalArchiveCount: 10, MainCategory: 1, Fans: 100, ApplyAt: xtime.Time(time.Now().Unix())}
  18. _, err := d.InsertBlocked(context.Background(), v)
  19. So(err, ShouldBeNil)
  20. }))
  21. Convey("update blocked is_deleted", t, WithMysql(func(d *Dao) {
  22. var (
  23. mid int64 = 1011
  24. del = 1
  25. )
  26. _, err := d.UpdateBlockedState(context.Background(), mid, del)
  27. So(err, ShouldBeNil)
  28. }))
  29. Convey("del blocked", t, WithMysql(func(d *Dao) {
  30. var (
  31. mid int64 = 1011
  32. )
  33. _, err := d.DelFromBlocked(context.Background(), mid)
  34. So(err, ShouldBeNil)
  35. }))
  36. Convey("get blocked count", t, WithMysql(func(d *Dao) {
  37. var (
  38. query = "1 = 1"
  39. )
  40. _, err := d.BlockCount(context.Background(), query)
  41. So(err, ShouldBeNil)
  42. }))
  43. Convey("query blocked user in black list", t, WithMysql(func(d *Dao) {
  44. var (
  45. query = "1 = 1"
  46. )
  47. _, err := d.QueryFromBlocked(context.Background(), query)
  48. So(err, ShouldBeNil)
  49. }))
  50. Convey("check user is blocked", t, WithMysql(func(d *Dao) {
  51. var (
  52. mid int64 = 1011
  53. )
  54. _, err := d.Blocked(context.Background(), mid)
  55. So(err, ShouldBeNil)
  56. }))
  57. }