hbase_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/secure/model"
  6. xtime "go-common/library/time"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestAddLocs(t *testing.T) {
  10. Convey("TestAddLocs", t, func() {
  11. err := d.AddLocs(context.TODO(), 2, 3, 11)
  12. d.AddLocs(context.TODO(), 2, 4, 12)
  13. d.AddLocs(context.TODO(), 2, 4, 13)
  14. d.AddLocs(context.TODO(), 2, 4, 14)
  15. d.AddLocs(context.TODO(), 2, 3, 15)
  16. So(err, ShouldBeNil)
  17. })
  18. }
  19. func TestLocs(t *testing.T) {
  20. Convey("TestLocs", t, func() {
  21. locs, err := d.Locs(context.TODO(), 2)
  22. So(err, ShouldBeNil)
  23. So(locs, ShouldNotBeNil)
  24. })
  25. }
  26. func TestAddEcpt(t *testing.T) {
  27. Convey("TestAddEcpt", t, func() {
  28. err := d.AddException(context.TODO(), &model.Log{Mid: 2, Time: xtime.Time(1111), IP: 222, LocationID: 3, Location: "aa"})
  29. So(err, ShouldBeNil)
  30. err = d.AddException(context.TODO(), &model.Log{Mid: 2, Time: xtime.Time(1311), IP: 222, LocationID: 3, Location: "aa"})
  31. So(err, ShouldBeNil)
  32. err = d.AddException(context.TODO(), &model.Log{Mid: 2333, Time: xtime.Time(1111), IP: 222, LocationID: 3, Location: "aa"})
  33. So(err, ShouldBeNil)
  34. })
  35. }
  36. func TestAddFeedBack(t *testing.T) {
  37. Convey("TestAddFeedBack", t, func() {
  38. err := d.AddFeedBack(context.TODO(), &model.Log{Mid: 2, Time: xtime.Time(1111), IP: 222, Type: 2, LocationID: 3, Location: "aa"})
  39. if err != nil {
  40. t.Errorf("test hbase add err %v", err)
  41. }
  42. })
  43. }
  44. func TestExcep(t *testing.T) {
  45. Convey("TestExcep", t, func() {
  46. locs, err := d.ExceptionLoc(context.TODO(), 2)
  47. if err != nil {
  48. t.Errorf("test hbase add err %v", err)
  49. } else {
  50. for _, l := range locs {
  51. t.Logf("locs %v", l)
  52. }
  53. }
  54. })
  55. }