monitor_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoAddMonitor(t *testing.T) {
  8. convey.Convey("AddMonitor", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. mid = int64(1)
  12. operator = "aa"
  13. remark = "aa"
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. err := d.AddMonitor(c, mid, operator, remark)
  17. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoMonitors(t *testing.T) {
  24. convey.Convey("Monitors", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. mid = int64(1)
  28. pn = int(0)
  29. ps = int(10)
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. mns, total, err := d.Monitors(c, mid, false, pn, ps)
  33. ctx.Convey("Then err should be nil.mns,total should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(total, convey.ShouldNotBeNil)
  36. ctx.So(mns, convey.ShouldNotBeNil)
  37. })
  38. })
  39. })
  40. }
  41. func TestDaoDelMonitor(t *testing.T) {
  42. convey.Convey("DelMonitor", t, func(ctx convey.C) {
  43. var (
  44. c = context.Background()
  45. mid = int64(1)
  46. operator = "aa"
  47. remark = "aa"
  48. )
  49. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  50. err := d.DelMonitor(c, mid, operator, remark)
  51. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  52. ctx.So(err, convey.ShouldBeNil)
  53. })
  54. })
  55. })
  56. }