mysql_test.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoLoadNotify(t *testing.T) {
  8. var (
  9. c = context.TODO()
  10. )
  11. convey.Convey("LoadNotify", t, func(ctx convey.C) {
  12. _, err := d.LoadNotify(c, "sh001")
  13. ctx.Convey("Then err should be nil.ns should not be nil.", func(ctx convey.C) {
  14. ctx.So(err, convey.ShouldBeNil)
  15. //ctx.So(ns, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoLoadPub(t *testing.T) {
  20. var (
  21. c = context.TODO()
  22. )
  23. convey.Convey("LoadPub", t, func(ctx convey.C) {
  24. _, err := d.LoadPub(c)
  25. ctx.Convey("Then err should be nil.ps should not be nil.", func(ctx convey.C) {
  26. ctx.So(err, convey.ShouldBeNil)
  27. // ctx.So(ps, convey.ShouldNotBeNil)
  28. })
  29. })
  30. }
  31. func TestDaoFilters(t *testing.T) {
  32. var (
  33. c = context.TODO()
  34. id = int64(7)
  35. )
  36. convey.Convey("Filters", t, func(ctx convey.C) {
  37. fs, err := d.Filters(c, id)
  38. ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldBeNil)
  40. ctx.So(fs, convey.ShouldNotBeNil)
  41. })
  42. })
  43. }
  44. func TestDaoAddFailBk(t *testing.T) {
  45. var (
  46. c = context.TODO()
  47. topic = ""
  48. group = ""
  49. cluster = ""
  50. msg = ""
  51. index = int64(0)
  52. )
  53. convey.Convey("AddFailBk", t, func(ctx convey.C) {
  54. id, err := d.AddFailBk(c, topic, group, cluster, msg, index)
  55. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  56. ctx.So(err, convey.ShouldBeNil)
  57. ctx.So(id, convey.ShouldNotBeNil)
  58. })
  59. })
  60. }
  61. func TestDaoDelFailBk(t *testing.T) {
  62. var (
  63. c = context.TODO()
  64. id = int64(0)
  65. )
  66. convey.Convey("DelFailBk", t, func(ctx convey.C) {
  67. affected, err := d.DelFailBk(c, id)
  68. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  69. ctx.So(err, convey.ShouldBeNil)
  70. ctx.So(affected, convey.ShouldNotBeNil)
  71. })
  72. })
  73. }
  74. func TestDaoLoadFailBk(t *testing.T) {
  75. var (
  76. c = context.TODO()
  77. )
  78. convey.Convey("LoadFailBk", t, func(ctx convey.C) {
  79. fbs, err := d.LoadFailBk(c)
  80. ctx.Convey("Then err should be nil.fbs should not be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldBeNil)
  82. ctx.So(fbs, convey.ShouldNotBeNil)
  83. })
  84. })
  85. }