utils_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package dao
  2. import (
  3. "testing"
  4. "github.com/smartystreets/goconvey/convey"
  5. )
  6. func TestDaoConcatCondition(t *testing.T) {
  7. var (
  8. conditions Condition
  9. )
  10. convey.Convey("ConcatCondition", t, func(ctx convey.C) {
  11. conditionStr, args, hasOperator := ConcatCondition(conditions)
  12. ctx.Convey("Then conditionStr,args,hasOperator should not be nil.", func(ctx convey.C) {
  13. ctx.So(hasOperator, convey.ShouldNotBeNil)
  14. ctx.So(args, convey.ShouldBeNil)
  15. ctx.So(conditionStr, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoAndCondition(t *testing.T) {
  20. var (
  21. conditions Condition
  22. )
  23. convey.Convey("AndCondition", t, func(ctx convey.C) {
  24. result := AndCondition(conditions)
  25. ctx.Convey("Then result should not be nil.", func(ctx convey.C) {
  26. ctx.So(result, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestDaoOrCondition(t *testing.T) {
  31. var (
  32. conditions Condition
  33. )
  34. convey.Convey("OrCondition", t, func(ctx convey.C) {
  35. result := OrCondition(conditions)
  36. ctx.Convey("Then result should not be nil.", func(ctx convey.C) {
  37. ctx.So(result, convey.ShouldNotBeNil)
  38. })
  39. })
  40. }
  41. func TestDaoaddLogicOperator(t *testing.T) {
  42. var (
  43. operator = int(0)
  44. conditions Condition
  45. )
  46. convey.Convey("addLogicOperator", t, func(ctx convey.C) {
  47. result := addLogicOperator(operator, conditions)
  48. ctx.Convey("Then result should not be nil.", func(ctx convey.C) {
  49. ctx.So(result, convey.ShouldNotBeNil)
  50. })
  51. })
  52. }
  53. func TestSplit(t *testing.T) {
  54. var (
  55. start = 0
  56. end = 100
  57. size = 10
  58. f = func(start int, end int) {}
  59. )
  60. convey.Convey("split", t, func(ctx convey.C) {
  61. Split(start, end, size, f)
  62. })
  63. }