http_test.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoaddVolumeURI(t *testing.T) {
  8. convey.Convey("addVolumeURI", t, func(ctx convey.C) {
  9. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  10. p1 := d.addVolumeURI()
  11. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  12. ctx.So(p1, convey.ShouldNotBeNil)
  13. })
  14. })
  15. })
  16. }
  17. func TestDaoaddFreeVolumeURI(t *testing.T) {
  18. convey.Convey("addFreeVolumeURI", t, func(ctx convey.C) {
  19. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  20. p1 := d.addFreeVolumeURI()
  21. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  22. ctx.So(p1, convey.ShouldNotBeNil)
  23. })
  24. })
  25. })
  26. }
  27. func TestDaocompactURI(t *testing.T) {
  28. convey.Convey("compactURI", t, func(ctx convey.C) {
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. p1 := d.compactURI()
  31. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  32. ctx.So(p1, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestDaogroupStatusURI(t *testing.T) {
  38. convey.Convey("groupStatusURI", t, func(ctx convey.C) {
  39. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  40. p1 := d.groupStatusURI()
  41. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  42. ctx.So(p1, convey.ShouldNotBeNil)
  43. })
  44. })
  45. })
  46. }
  47. // func TestDaoAddVolume(t *testing.T) {
  48. // convey.Convey("AddVolume", t, func(ctx convey.C) {
  49. // var (
  50. // c = context.Background()
  51. // group = "1"
  52. // num = int64(1)
  53. // )
  54. // ctx.Convey("add one volume to group 1", func(ctx convey.C) {
  55. // err := d.AddVolume(c, group, num)
  56. // if strings.Contains(err.Error(), "store response status code:7001") {
  57. // t.Log("store have no free volume")
  58. // err = nil // NOTE ignore error
  59. // }
  60. // ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  61. // ctx.So(err, convey.ShouldBeNil)
  62. // })
  63. // })
  64. // })
  65. // }
  66. // func TestDaoAddFreeVolume(t *testing.T) {
  67. // convey.Convey("AddFreeVolume", t, func(ctx convey.C) {
  68. // var (
  69. // c = context.Background()
  70. // group = "1"
  71. // dir = "/mnt/storage00/bfsdata"
  72. // num = int64(1)
  73. // )
  74. // ctx.Convey("When everything goes positive", func(ctx convey.C) {
  75. // err := d.AddFreeVolume(c, group, dir, num)
  76. // ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  77. // ctx.So(err, convey.ShouldBeNil)
  78. // })
  79. // })
  80. // })
  81. // }
  82. func TestDaoCompact(t *testing.T) {
  83. convey.Convey("Compact", t, func(ctx convey.C) {
  84. var (
  85. c = context.Background()
  86. group = "1"
  87. vid = int64(1)
  88. )
  89. ctx.Convey("compact group:1 vid:1", func(ctx convey.C) {
  90. err := d.Compact(c, group, vid)
  91. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  92. ctx.So(err, convey.ShouldBeNil)
  93. })
  94. })
  95. })
  96. }
  97. func TestDaoSetGroupStatus(t *testing.T) {
  98. convey.Convey("SetGroupStatus", t, func(ctx convey.C) {
  99. var (
  100. c = context.Background()
  101. group = "1"
  102. status = "health"
  103. )
  104. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  105. err := d.SetGroupStatus(c, group, status)
  106. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  107. ctx.So(err, convey.ShouldBeNil)
  108. })
  109. })
  110. })
  111. }