av_breach_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoGetAvBreach(t *testing.T) {
  8. convey.Convey("GetAvBreach", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. start = "2018-06-20"
  12. end = "2018-10-20"
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. avs, err := d.GetAvBreach(c, start, end)
  16. ctx.Convey("Then err should be nil.avs should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(avs, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoGetAvBreachPre(t *testing.T) {
  24. convey.Convey("GetAvBreachPre", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. ctype = int(1)
  28. state = int(3)
  29. cdate = "2018-10-23"
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. avs, err := d.GetAvBreachPre(c, ctype, state, cdate)
  33. ctx.Convey("Then err should be nil.avs should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(avs, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoInsertAvBreachPre(t *testing.T) {
  41. convey.Convey("InsertAvBreachPre", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. val = "100, 29, '2018-06-23', 1, 3"
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. Exec(c, "DELETE FROM av_breach_pre WHERE aid=100")
  48. rows, err := d.InsertAvBreachPre(c, 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. }