flow_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/aegis/model/net"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestServiceShowFlow(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. id = int64(1)
  12. )
  13. convey.Convey("ShowFlow", t, func(ctx convey.C) {
  14. r, err := s.ShowFlow(c, id)
  15. ctx.Convey("Then err should be nil.r should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(r, convey.ShouldNotBeNil)
  18. })
  19. })
  20. }
  21. func TestServiceGetFlowList(t *testing.T) {
  22. var (
  23. c = context.TODO()
  24. pm = &net.ListNetElementParam{}
  25. )
  26. convey.Convey("GetFlowList", t, func(ctx convey.C) {
  27. result, err := s.GetFlowList(c, pm)
  28. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. ctx.So(result, convey.ShouldNotBeNil)
  31. })
  32. })
  33. }
  34. func TestServicecheckFlowUnique(t *testing.T) {
  35. var (
  36. netID = int64(0)
  37. name = ""
  38. )
  39. convey.Convey("checkFlowUnique", t, func(ctx convey.C) {
  40. err, msg := s.checkFlowUnique(cntx, netID, name)
  41. ctx.Convey("Then err should be nil.msg should not be nil.", func(ctx convey.C) {
  42. ctx.So(msg, convey.ShouldNotBeNil)
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. }
  47. func TestServicetaskFlowByBusiness(t *testing.T) {
  48. var (
  49. c = context.TODO()
  50. )
  51. convey.Convey("dispatchFlow", t, func(ctx convey.C) {
  52. res, err := s.dispatchFlow(c, []int64{1, 2}, []int64{1, 2})
  53. for biz, item := range res {
  54. t.Logf("biz(%d) flows(%+v)", biz, item)
  55. }
  56. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldBeNil)
  58. })
  59. })
  60. }