business_config_test.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package gorm
  2. import (
  3. "context"
  4. "go-common/app/admin/main/aegis/model/business"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestGormGetConfigs(t *testing.T) {
  9. convey.Convey("GetConfigs", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. bizid = int64(1)
  13. )
  14. ctx.Convey("success", func(ctx convey.C) {
  15. cfgs, err := d.GetConfigs(c, bizid)
  16. ctx.Convey("Then err should be nil.cfgs should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(cfgs, convey.ShouldNotBeNil)
  19. })
  20. })
  21. ctx.Convey("empty", func(ctx convey.C) {
  22. _, err := d.GetConfigs(c, -1)
  23. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  24. ctx.So(err, convey.ShouldBeNil)
  25. })
  26. })
  27. })
  28. }
  29. func TestGormGetConfig(t *testing.T) {
  30. convey.Convey("GetConfig", t, func(ctx convey.C) {
  31. var (
  32. c = context.Background()
  33. bizid = int64(0)
  34. tp = int8(-1)
  35. )
  36. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  37. config, err := d.GetConfig(c, bizid, tp)
  38. ctx.Convey("Then err should be nil.config should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldBeNil)
  40. ctx.So(config, convey.ShouldNotBeNil)
  41. })
  42. })
  43. })
  44. }
  45. func TestGormActiveConfigs(t *testing.T) {
  46. convey.Convey("ActiveConfigs", t, func(ctx convey.C) {
  47. var (
  48. c = context.Background()
  49. )
  50. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  51. configs, err := d.ActiveConfigs(c)
  52. ctx.Convey("Then err should be nil.configs should not be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. ctx.So(configs, convey.ShouldNotBeNil)
  55. })
  56. })
  57. })
  58. }
  59. func TestGormAddBizConfig(t *testing.T) {
  60. convey.Convey("AddBizConfig", t, func(ctx convey.C) {
  61. var (
  62. c = context.Background()
  63. cfg = &business.BizCFG{}
  64. )
  65. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  66. lastid, err := d.AddBizConfig(c, cfg)
  67. ctx.Convey("Then err should be nil.lastid should not be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldBeNil)
  69. ctx.So(lastid, convey.ShouldNotBeNil)
  70. })
  71. })
  72. })
  73. }
  74. func TestGormEditBizConfig(t *testing.T) {
  75. convey.Convey("EditBizConfig", t, func(ctx convey.C) {
  76. var (
  77. c = context.Background()
  78. cfg = &business.BizCFG{}
  79. )
  80. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  81. err := d.EditBizConfig(c, cfg)
  82. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  83. ctx.So(err, convey.ShouldBeNil)
  84. })
  85. })
  86. })
  87. }