mysql_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaohit(t *testing.T) {
  8. convey.Convey("hit", t, func(ctx convey.C) {
  9. var (
  10. mid = int64(46333)
  11. )
  12. ctx.Convey("When everything right.", func(ctx convey.C) {
  13. shard := hit(mid)
  14. ctx.Convey("Then shard should not be mid % 100.", func(ctx convey.C) {
  15. ctx.So(shard, convey.ShouldEqual, 33)
  16. })
  17. })
  18. })
  19. }
  20. func TestDaoFigureInfo(t *testing.T) {
  21. convey.Convey("FigureInfo", t, func(ctx convey.C) {
  22. var (
  23. c = context.Background()
  24. mid = int64(20606508)
  25. )
  26. ctx.Convey("When everything right.", func(ctx convey.C) {
  27. res, err := d.FigureInfo(c, mid)
  28. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. ctx.So(res, convey.ShouldNotBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaoRanks(t *testing.T) {
  36. convey.Convey("Ranks", t, func(ctx convey.C) {
  37. var (
  38. c = context.Background()
  39. )
  40. ctx.Convey("When everything right.", func(ctx convey.C) {
  41. ranks, err := d.Ranks(c)
  42. ctx.Convey("Then err should be nil.ranks should have length 100.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. ctx.So(ranks, convey.ShouldHaveLength, 100)
  45. })
  46. })
  47. })
  48. }