memcache_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package template
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/model/template"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestTemplatekeyTpl(t *testing.T) {
  9. var (
  10. mid = int64(2089809)
  11. )
  12. convey.Convey("keyTpl", t, func(ctx convey.C) {
  13. p1 := keyTpl(mid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestTemplatetplCache(t *testing.T) {
  20. var (
  21. c = context.TODO()
  22. mid = int64(2089809)
  23. )
  24. convey.Convey("tplCache", t, func(ctx convey.C) {
  25. tps, err := d.tplCache(c, mid)
  26. ctx.Convey("Then err should be nil.tps should not be nil.", func(ctx convey.C) {
  27. ctx.So(err, convey.ShouldBeNil)
  28. ctx.So(tps, convey.ShouldBeNil)
  29. })
  30. })
  31. }
  32. func TestTemplateaddTplCache(t *testing.T) {
  33. var (
  34. c = context.TODO()
  35. mid = int64(2089809)
  36. tps = []*template.Template{}
  37. )
  38. convey.Convey("addTplCache", t, func(ctx convey.C) {
  39. err := d.addTplCache(c, mid, tps)
  40. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  41. ctx.So(err, convey.ShouldBeNil)
  42. })
  43. })
  44. }
  45. func TestTemplatedelTplCache(t *testing.T) {
  46. var (
  47. c = context.TODO()
  48. mid = int64(2089809)
  49. )
  50. convey.Convey("delTplCache", t, func(ctx convey.C) {
  51. err := d.delTplCache(c, mid)
  52. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. })
  55. })
  56. }