hbase_face_test.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. "github.com/tsuna/gohbase/hrpc"
  7. )
  8. func TestDaoFaceApplies(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. mid = int64(100)
  12. from, to = int64(0), int64(_uint32Max)
  13. status = ""
  14. operator = ""
  15. )
  16. convey.Convey("FaceApplies", t, func(ctx convey.C) {
  17. _, err := d.FaceApplies(c, mid, from, to, status, operator)
  18. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. //ctx.So(res, convey.ShouldNotBeNil)
  21. //
  22. //lastTs := int64(0)
  23. //lastID := int64(0)
  24. //for _, v := range res {
  25. // ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  26. // mt, err := time.ParseInLocation(_inputFormat, v.ModifyTime, _loc)
  27. // ctx.So(err, convey.ShouldBeNil)
  28. //
  29. // id, err := strconv.ParseInt(v.Operator, 10, 64)
  30. // ctx.So(err, convey.ShouldBeNil)
  31. //
  32. // // check ts seq
  33. // ts := mt.Unix()
  34. // if lastTs > 0 {
  35. // ctx.So(lastTs, convey.ShouldBeGreaterThanOrEqualTo, ts)
  36. // }
  37. //
  38. // // check id seq when ts equal
  39. // if lastTs == ts && lastID > 0 {
  40. // ctx.So(lastID, convey.ShouldBeGreaterThan, id)
  41. // }
  42. //
  43. // lastTs = ts
  44. // lastID = id
  45. // })
  46. //}
  47. })
  48. })
  49. }
  50. func TestDaorowKeyFaceApplyMts(t *testing.T) {
  51. var (
  52. midStr = "123"
  53. mts = int64(0)
  54. id = int64(0)
  55. )
  56. convey.Convey("rowKeyFaceApplyMts", t, func(ctx convey.C) {
  57. p1 := rowKeyFaceApplyMts(midStr, mts, id)
  58. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  59. ctx.So(p1, convey.ShouldNotBeNil)
  60. })
  61. })
  62. }
  63. func TestDaoscanFaceRecord(t *testing.T) {
  64. var (
  65. cells = []*hrpc.Cell{
  66. {Family: []byte("c"), Qualifier: []byte("mid"), Value: []byte("123")},
  67. {Family: []byte("c"), Qualifier: []byte("at"), Value: []byte("1530846373")},
  68. {Family: []byte("c"), Qualifier: []byte("mt"), Value: []byte("1530846373")},
  69. {Family: []byte("c"), Qualifier: []byte("nf"), Value: []byte("nf")},
  70. {Family: []byte("c"), Qualifier: []byte("of"), Value: []byte("of")},
  71. {Family: []byte("c"), Qualifier: []byte("op"), Value: []byte("op")},
  72. {Family: []byte("c"), Qualifier: []byte("s"), Value: []byte("0")},
  73. }
  74. )
  75. convey.Convey("scanFaceRecord", t, func(ctx convey.C) {
  76. res, err := scanFaceRecord(cells)
  77. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. ctx.So(res, convey.ShouldNotBeNil)
  80. })
  81. })
  82. }