up_group_test.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package manager
  2. import (
  3. "context"
  4. "go-common/app/service/main/up/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. "strings"
  8. )
  9. func TestManagerAddGroup(t *testing.T) {
  10. var (
  11. c = context.TODO()
  12. groupAddInfo = &model.AddGroupArg{}
  13. )
  14. convey.Convey("AddGroup", t, func(ctx convey.C) {
  15. _, err := d.AddGroup(c, groupAddInfo)
  16. if strings.Contains(err.Error(), "Error 1062") {
  17. err = nil
  18. }
  19. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. })
  22. })
  23. }
  24. func TestManagerCheckGroupExist(t *testing.T) {
  25. var (
  26. c = context.TODO()
  27. groupAddInfo = &model.AddGroupArg{}
  28. exceptid = int64(0)
  29. )
  30. convey.Convey("CheckGroupExist", t, func(ctx convey.C) {
  31. exist, err := d.CheckGroupExist(c, groupAddInfo, exceptid)
  32. ctx.Convey("Then err should be nil.exist should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(exist, convey.ShouldNotBeNil)
  35. })
  36. })
  37. }
  38. func TestManagerUpdateGroup(t *testing.T) {
  39. var (
  40. c = context.TODO()
  41. groupAddInfo = &model.EditGroupArg{}
  42. )
  43. convey.Convey("UpdateGroup", t, func(ctx convey.C) {
  44. res, err := d.UpdateGroup(c, groupAddInfo)
  45. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  46. ctx.So(err, convey.ShouldBeNil)
  47. ctx.So(res, convey.ShouldBeNil)
  48. })
  49. })
  50. }
  51. func TestManagerRemoveGroup(t *testing.T) {
  52. var (
  53. c = context.TODO()
  54. arg = &model.RemoveGroupArg{}
  55. )
  56. convey.Convey("RemoveGroup", t, func(ctx convey.C) {
  57. res, err := d.RemoveGroup(c, arg)
  58. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. ctx.So(res, convey.ShouldNotBeNil)
  61. })
  62. })
  63. }
  64. func TestManagerGetGroup(t *testing.T) {
  65. var (
  66. c = context.TODO()
  67. arg = &model.GetGroupArg{}
  68. )
  69. convey.Convey("GetGroup", t, func(ctx convey.C) {
  70. _, err := d.GetGroup(c, arg)
  71. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. }