search_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package http
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. "go-common/app/admin/main/aegis/model"
  7. )
  8. var arg = &model.SearchParams{
  9. BusinessID: 1,
  10. //CtimeFrom: "2018-01-01 01:01:01",
  11. //CtimeTo: "2019-11-11 11:11:11",
  12. OID: []string{"206137981869783258", "206137981871880409", "206129056929839317", "206117679558326449"},
  13. KeyWord: "分享图片",
  14. FlowID: -12345,
  15. Extra1: "1,2,3,4,5",
  16. Mid: -12345,
  17. State: 0,
  18. }
  19. func TestHttpResourceES(t *testing.T) {
  20. convey.Convey("ResourceES", t, func(ctx convey.C) {
  21. var (
  22. c = context.Background()
  23. )
  24. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  25. res, err := d.ResourceES(c, arg)
  26. t.Logf("res(%+v)", res)
  27. ctx.Convey("Then err should be nil.sres should not be nil.", func(ctx convey.C) {
  28. ctx.So(err, convey.ShouldBeNil)
  29. })
  30. })
  31. })
  32. }
  33. func TestUpsertES(t *testing.T) {
  34. convey.Convey("UpsertES", t, func(ctx convey.C) {
  35. rsc := []*model.UpsertItem{
  36. {
  37. ID: 47,
  38. State: -3,
  39. },
  40. nil,
  41. {
  42. State: 0,
  43. },
  44. }
  45. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  46. httpMock("POST", d.c.Host.Manager+_upsertES).Reply(200).JSON(`{"code":0,"message":"msg"}`)
  47. err := d.UpsertES(context.Background(), rsc)
  48. ctx.Convey("No return values", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. })
  51. })
  52. })
  53. }