transition_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/main/aegis/model/net"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestServicecreateTaskVerify(t *testing.T) {
  9. var (
  10. rid = int64(1)
  11. flowID = int64(1)
  12. bizid = int64(1)
  13. )
  14. convey.Convey("prepareBeforeTrigger", t, func(ctx convey.C) {
  15. err := s.prepareBeforeTrigger(context.TODO(), []int64{rid}, flowID, bizid)
  16. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. })
  19. })
  20. }
  21. func TestServiceShowTransition(t *testing.T) {
  22. var (
  23. c = context.TODO()
  24. id = int64(1)
  25. )
  26. convey.Convey("ShowTransition", t, func(ctx convey.C) {
  27. r, err := s.ShowTransition(c, id)
  28. ctx.Convey("Then err should be nil.r should not be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. ctx.So(r, convey.ShouldNotBeNil)
  31. })
  32. })
  33. }
  34. func TestServiceGetTransitionList(t *testing.T) {
  35. var (
  36. c = context.TODO()
  37. pm = &net.ListNetElementParam{NetID: 1}
  38. )
  39. convey.Convey("GetTransitionList", t, func(ctx convey.C) {
  40. result, err := s.GetTransitionList(c, pm)
  41. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. ctx.So(result, convey.ShouldNotBeNil)
  44. })
  45. })
  46. }
  47. func TestServicecheckTransitionUnique(t *testing.T) {
  48. var (
  49. netID = int64(1)
  50. name = ""
  51. )
  52. convey.Convey("checkTransitionUnique", t, func(ctx convey.C) {
  53. err, msg := s.checkTransitionUnique(cntx, netID, name)
  54. ctx.Convey("Then err should be nil.msg should not be nil.", func(ctx convey.C) {
  55. ctx.So(msg, convey.ShouldNotBeNil)
  56. ctx.So(err, convey.ShouldBeNil)
  57. })
  58. })
  59. }