sear_inter_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/tv/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoSetSearInterRankCache(t *testing.T) {
  10. var (
  11. c = context.Background()
  12. rank = []*model.OutSearchInter{}
  13. )
  14. convey.Convey("SetSearchInterv", t, func(ctx convey.C) {
  15. rank = append(rank, &model.OutSearchInter{
  16. Keyword: "key",
  17. Status: "1",
  18. })
  19. err := d.SetSearchInterv(c, rank)
  20. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. })
  23. })
  24. }
  25. func TestDaoGetSearInterRankCache(t *testing.T) {
  26. var (
  27. c = context.Background()
  28. )
  29. convey.Convey("GetSearchInterv", t, func(ctx convey.C) {
  30. rank, err := d.GetSearchInterv(c)
  31. ctx.Convey("Then err should be nil.rank should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(rank, convey.ShouldNotBeNil)
  34. })
  35. })
  36. }
  37. func TestDaoSetPublishCache(t *testing.T) {
  38. var (
  39. c = context.Background()
  40. state = &model.PublishStatus{
  41. Time: time.Now().Format("2006-01-02 15:04:05"),
  42. State: 1,
  43. }
  44. )
  45. convey.Convey("SetPublishCache", t, func(ctx convey.C) {
  46. err := d.SetPublishCache(c, state)
  47. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. })
  50. })
  51. }
  52. func TestDaoGetPublishCache(t *testing.T) {
  53. var (
  54. c = context.Background()
  55. )
  56. convey.Convey("GetPublishCache", t, func(ctx convey.C) {
  57. state, err := d.GetPublishCache(c)
  58. ctx.Convey("Then err should be nil.state should not be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. ctx.So(state, convey.ShouldNotBeNil)
  61. })
  62. })
  63. }