fold_test.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/reply/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoTxCountFoldedReplies(t *testing.T) {
  9. convey.Convey("TxCountFoldedReplies", t, func(ctx convey.C) {
  10. var (
  11. tx, _ = d.BeginTran(context.Background())
  12. oid = int64(0)
  13. tp = int32(0)
  14. root = int64(0)
  15. )
  16. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  17. count, err := d.TxCountFoldedReplies(tx, oid, tp, root)
  18. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. ctx.So(count, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoFoldedReplies(t *testing.T) {
  26. convey.Convey("FoldedReplies", t, func(ctx convey.C) {
  27. var (
  28. c = context.Background()
  29. oid = int64(0)
  30. tp = int32(0)
  31. root = int64(0)
  32. )
  33. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  34. rps, err := d.FoldedReplies(c, oid, tp, root)
  35. ctx.Convey("Then err should be nil.rps should not be nil.", func(ctx convey.C) {
  36. ctx.So(err, convey.ShouldBeNil)
  37. ctx.So(rps, convey.ShouldBeNil)
  38. })
  39. })
  40. })
  41. }
  42. func TestDaoRemRdsByFold(t *testing.T) {
  43. convey.Convey("RemRdsByFold", t, func(ctx convey.C) {
  44. var (
  45. c = context.Background()
  46. roots = []int64{}
  47. childMap map[int64][]int64
  48. sub = &model.Subject{}
  49. rpMap map[int64]*model.Reply
  50. )
  51. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  52. d.RemRdsByFold(c, roots, childMap, sub, rpMap)
  53. ctx.Convey("No return values", func(ctx convey.C) {
  54. })
  55. })
  56. })
  57. }
  58. func TestDaoAddRdsByFold(t *testing.T) {
  59. convey.Convey("AddRdsByFold", t, func(ctx convey.C) {
  60. var (
  61. c = context.Background()
  62. roots = []int64{}
  63. childMap map[int64][]int64
  64. sub = &model.Subject{}
  65. rpMap map[int64]*model.Reply
  66. )
  67. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  68. d.AddRdsByFold(c, roots, childMap, sub, rpMap)
  69. ctx.Convey("No return values", func(ctx convey.C) {
  70. })
  71. })
  72. })
  73. }