direction_test.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package gorm
  2. import (
  3. "testing"
  4. "go-common/app/admin/main/aegis/model/net"
  5. "go-common/library/ecode"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoDirectionByTransitionID(t *testing.T) {
  9. convey.Convey("DirectionByTransitionID", t, func(ctx convey.C) {
  10. _, err := d.DirectionByTransitionID(cntx, []int64{}, 1, true)
  11. ctx.Convey("Then err should be nil", func(ctx convey.C) {
  12. ctx.So(err, convey.ShouldBeNil)
  13. })
  14. })
  15. }
  16. func TestDaoDirectionByID(t *testing.T) {
  17. convey.Convey("DirectionByID", t, func(ctx convey.C) {
  18. _, err := d.DirectionByID(cntx, -1)
  19. ctx.Convey("Then err should be 404", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldEqual, ecode.NothingFound)
  21. })
  22. })
  23. }
  24. func TestDaoDirectionList(t *testing.T) {
  25. var (
  26. pm = &net.ListDirectionParam{
  27. NetID: 1,
  28. Ps: 20,
  29. ID: []int64{1},
  30. FlowID: 1,
  31. TransitionID: 1,
  32. Direction: 1,
  33. }
  34. )
  35. convey.Convey("DirectionList", t, func(ctx convey.C) {
  36. result, err := d.DirectionList(cntx, pm)
  37. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  38. ctx.So(err, convey.ShouldBeNil)
  39. ctx.So(result, convey.ShouldNotBeNil)
  40. t.Logf("list result(%+v)", result)
  41. for _, dir := range result.Result {
  42. t.Logf("bylist dir(%+v)", dir)
  43. }
  44. })
  45. })
  46. }
  47. func TestDaoDirectionByUnique(t *testing.T) {
  48. convey.Convey("DirectionByUnique", t, func(ctx convey.C) {
  49. _, err := d.DirectionByUnique(cntx, 0, 0, 0, 0)
  50. ctx.Convey("Then err should be nil", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. })
  53. })
  54. }
  55. func TestDaoDirectionByFlowID(t *testing.T) {
  56. convey.Convey("DirectionByFlowID", t, func(ctx convey.C) {
  57. _, err := d.DirectionByFlowID(cntx, []int64{}, 1)
  58. ctx.Convey("Then err should be nil", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. })
  61. })
  62. }
  63. func TestDaoDirectionByNet(t *testing.T) {
  64. convey.Convey("DirectionByNet", t, func(ctx convey.C) {
  65. _, err := d.DirectionByNet(cntx, 0)
  66. ctx.Convey("Then err should be nil", func(ctx convey.C) {
  67. ctx.So(err, convey.ShouldBeNil)
  68. })
  69. })
  70. }
  71. func TestDaoDirections(t *testing.T) {
  72. convey.Convey("Directions", t, func(ctx convey.C) {
  73. _, err := d.Directions(cntx, []int64{0})
  74. ctx.Convey("Then err should be nil", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. })
  77. })
  78. }