net_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package gorm
  2. import (
  3. "testing"
  4. "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/admin/main/aegis/model/net"
  6. )
  7. func TestDaoNetByID(t *testing.T) {
  8. convey.Convey("NetByID", t, func(ctx convey.C) {
  9. d.NetByID(cntx, 1)
  10. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  11. })
  12. })
  13. }
  14. func TestDao_NetList(t *testing.T) {
  15. convey.Convey("NetList", t, func(ctx convey.C) {
  16. pm := &net.ListNetParam{
  17. BusinessID: 1,
  18. //State: net.StateAvailable,
  19. Ps: 20,
  20. Pn: 1,
  21. ID: []int64{1},
  22. }
  23. _, err := d.NetList(cntx, pm)
  24. convey.So(err, convey.ShouldBeNil)
  25. })
  26. }
  27. func TestDaoNetIDByBusiness(t *testing.T) {
  28. convey.Convey("NetIDByBusiness", t, func(ctx convey.C) {
  29. res, err := d.NetIDByBusiness(cntx, []int64{1, 2, 3})
  30. t.Logf("res(%+v)", res)
  31. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. })
  34. })
  35. }
  36. func TestDaoNetsByBusiness(t *testing.T) {
  37. convey.Convey("NetsByBusiness", t, func(ctx convey.C) {
  38. _, err := d.NetsByBusiness(cntx, []int64{1}, true)
  39. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  40. ctx.So(err, convey.ShouldBeNil)
  41. })
  42. })
  43. }
  44. func TestDaoNets(t *testing.T) {
  45. convey.Convey("Nets", t, func(ctx convey.C) {
  46. _, err := d.Nets(cntx, []int64{})
  47. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. })
  50. })
  51. }
  52. func TestDaoNetByUnique(t *testing.T) {
  53. convey.Convey("NetByUnique", t, func(ctx convey.C) {
  54. _, err := d.NetByUnique(cntx, "")
  55. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  56. ctx.So(err, convey.ShouldBeNil)
  57. })
  58. })
  59. }
  60. func TestDaoNetBindStartFlow(t *testing.T) {
  61. var (
  62. tx, _ = d.BeginTx(cntx)
  63. )
  64. defer tx.Commit()
  65. convey.Convey("NetBindStartFlow", t, func(ctx convey.C) {
  66. err := d.NetBindStartFlow(cntx, tx, 0, 0)
  67. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldBeNil)
  69. })
  70. })
  71. }
  72. func TestDaoDisableNet(t *testing.T) {
  73. var (
  74. tx, _ = d.BeginTx(cntx)
  75. )
  76. defer tx.Commit()
  77. convey.Convey("DisableNet", t, func(ctx convey.C) {
  78. err := d.DisableNet(cntx, tx, 0)
  79. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  80. ctx.So(err, convey.ShouldBeNil)
  81. })
  82. })
  83. }