transition_test.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package gorm
  2. import (
  3. "go-common/app/admin/main/aegis/model/net"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. var tt = &net.Transition{
  8. ID: 1,
  9. NetID: 1,
  10. Trigger: net.TriggerManual,
  11. Name: "first",
  12. ChName: "第一次审核",
  13. Description: "新建变迁",
  14. UID: 421,
  15. }
  16. func TestDaoTransitionByID(t *testing.T) {
  17. convey.Convey("TransitionByID", t, func(ctx convey.C) {
  18. n, err := d.TransitionByID(cntx, tt.ID)
  19. ctx.Convey("Then err should be nil.n should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. ctx.So(n, convey.ShouldNotBeNil)
  22. })
  23. })
  24. }
  25. func TestDaoTransitionList(t *testing.T) {
  26. var (
  27. pm = &net.ListNetElementParam{
  28. NetID: 1,
  29. Ps: 20,
  30. ID: []int64{1},
  31. Name: "1",
  32. }
  33. )
  34. convey.Convey("TransitionList", t, func(ctx convey.C) {
  35. result, err := d.TransitionList(cntx, pm)
  36. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(result, convey.ShouldNotBeNil)
  39. })
  40. })
  41. }
  42. func TestDaoTransitions(t *testing.T) {
  43. convey.Convey("TransitionList", t, func(ctx convey.C) {
  44. _, err := d.Transitions(cntx, []int64{})
  45. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  46. ctx.So(err, convey.ShouldBeNil)
  47. })
  48. })
  49. }
  50. func TestDaoTransitionByUnique(t *testing.T) {
  51. convey.Convey("TransitionByUnique", t, func(ctx convey.C) {
  52. _, err := d.TransitionByUnique(cntx, 0, "")
  53. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  54. ctx.So(err, convey.ShouldBeNil)
  55. })
  56. })
  57. }
  58. func TestDaoTransitionIDByNet(t *testing.T) {
  59. convey.Convey("TransitionIDByNet", t, func(ctx convey.C) {
  60. a, err := d.TransitionIDByNet(cntx, []int64{1}, true, true)
  61. t.Logf("a(%+v)", a)
  62. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. })
  65. })
  66. }
  67. func TestDaoTranByNet(t *testing.T) {
  68. convey.Convey("TranByNet", t, func(ctx convey.C) {
  69. _, err := d.TranByNet(cntx, 0, true)
  70. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. })
  73. })
  74. }