creation_mc_test.go 692 B

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_SubmitCache(t *testing.T) {
  8. c := context.TODO()
  9. Convey("add cache", t, func() {
  10. err := d.AddSubmitCache(c, 100, "title")
  11. So(err, ShouldBeNil)
  12. Convey("get cache should work", func() {
  13. res, err1 := d.SubmitCache(c, 100, "title")
  14. So(err1, ShouldBeNil)
  15. So(res, ShouldBeTrue)
  16. res, err1 = d.SubmitCache(c, 200, "title")
  17. So(err1, ShouldBeNil)
  18. So(res, ShouldBeFalse)
  19. })
  20. Convey("delete cache should not present", func() {
  21. err = d.DelSubmitCache(c, 100, "title")
  22. So(err, ShouldBeNil)
  23. err = d.DelSubmitCache(c, 200, "title")
  24. So(err, ShouldBeNil)
  25. })
  26. })
  27. }