seq_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoAll(t *testing.T) {
  8. var (
  9. c = context.TODO()
  10. )
  11. convey.Convey("All", t, func(ctx convey.C) {
  12. bs, err := d.All(c)
  13. ctx.Convey("Then err should be nil.bs should not be nil.", func(ctx convey.C) {
  14. ctx.So(err, convey.ShouldBeNil)
  15. ctx.So(bs, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoMaxSeq(t *testing.T) {
  20. var (
  21. c = context.TODO()
  22. businessID = int64(2)
  23. )
  24. convey.Convey("MaxSeq", t, func(ctx convey.C) {
  25. maxSeq, err := d.MaxSeq(c, businessID)
  26. ctx.Convey("Then err should be nil.maxSeq should not be nil.", func(ctx convey.C) {
  27. ctx.So(err, convey.ShouldBeNil)
  28. ctx.So(maxSeq, convey.ShouldNotBeNil)
  29. })
  30. })
  31. }
  32. func TestDaoUpMaxSeq(t *testing.T) {
  33. var (
  34. c = context.TODO()
  35. businessID = int64(1)
  36. maxSeq = int64(10)
  37. lastSeq = int64(2)
  38. )
  39. convey.Convey("UpMaxSeq", t, func(ctx convey.C) {
  40. rows, err := d.UpMaxSeq(c, businessID, maxSeq, lastSeq)
  41. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. ctx.So(rows, convey.ShouldNotBeNil)
  44. })
  45. })
  46. }
  47. func TestDaoUpMaxSeqToken(t *testing.T) {
  48. var (
  49. c = context.TODO()
  50. businessID = int64(1)
  51. maxSeq = int64(10)
  52. step = int64(2)
  53. token = ""
  54. )
  55. convey.Convey("UpMaxSeqToken", t, func(ctx convey.C) {
  56. rows, err := d.UpMaxSeqToken(c, businessID, maxSeq, step, token)
  57. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldBeNil)
  59. ctx.So(rows, convey.ShouldNotBeNil)
  60. })
  61. })
  62. }