spy_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package spy
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. model "go-common/app/service/main/spy/model"
  7. )
  8. func TestSpy(t *testing.T) {
  9. s := New(nil)
  10. time.Sleep(2 * time.Second)
  11. testUpdateEventScore(t, s)
  12. testUpdateBaseScore(t, s)
  13. testUserScore(t, s)
  14. testHandleEvent(t, s)
  15. testReBuildPortrait(t, s)
  16. }
  17. func testUpdateEventScore(t *testing.T, s *Service) {
  18. t.Log(s.UpdateEventScore(context.TODO(), &model.ArgReset{Mid: 23333, Operator: "admin test"}))
  19. }
  20. func testUpdateBaseScore(t *testing.T, s *Service) {
  21. t.Log(s.UpdateBaseScore(context.TODO(), &model.ArgReset{Mid: 23333, Operator: "admin test"}))
  22. }
  23. func testUserScore(t *testing.T, s *Service) {
  24. t.Log(s.UserScore(context.TODO(), &model.ArgUserScore{Mid: 23333, IP: "127.0.0.1"}))
  25. }
  26. func testHandleEvent(t *testing.T, s *Service) {
  27. t.Log(s.HandleEvent(context.TODO(), &model.ArgHandleEvent{
  28. IP: "127.0.0.1",
  29. Service: "spy_service",
  30. Event: "bind_mail_only",
  31. ActiveMid: 23333,
  32. TargetMid: 23333,
  33. Effect: "",
  34. RiskLevel: 1,
  35. }))
  36. }
  37. func testReBuildPortrait(t *testing.T, s *Service) {
  38. t.Log(s.ReBuildPortrait(context.TODO(), &model.ArgReBuild{Mid: 23333}))
  39. }