AuthService_test.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package service
  2. import (
  3. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
  4. "fmt"
  5. "math/rand"
  6. "reflect"
  7. "testing"
  8. )
  9. func TestAuthService_UserAuthInfo(t *testing.T) {
  10. type args struct {
  11. in *medical.CommonReq
  12. }
  13. tests := []struct {
  14. name string
  15. args args
  16. want *map[string]interface{}
  17. }{
  18. // TODO: Add test cases.
  19. {
  20. name: "用户认证信息-认证",
  21. args: args{
  22. &medical.CommonReq{
  23. UserId: 123,
  24. Appid: "10000",
  25. },
  26. },
  27. },
  28. {
  29. name: "用户认证信息-未认证",
  30. args: args{
  31. &medical.CommonReq{
  32. UserId: rand.Int63n(100000000000),
  33. Appid: "10000",
  34. },
  35. },
  36. },
  37. }
  38. for _, tt := range tests {
  39. t.Run(tt.name, func(t *testing.T) {
  40. b := AuthService{}
  41. if got := b.UserAuthInfo(tt.args.in); !reflect.DeepEqual(got, tt.want) {
  42. t.Errorf("UserAuthInfo() = %v, want %v", got, tt.want)
  43. }
  44. })
  45. }
  46. }
  47. func TestAuthService_UserAuthInfoSave(t *testing.T) {
  48. type args struct {
  49. in *medical.UserInfo
  50. }
  51. tests := []struct {
  52. name string
  53. args args
  54. want bool
  55. want1 string
  56. }{
  57. // TODO: Add test cases.
  58. {
  59. name: "用户认证信息保存",
  60. args: args{
  61. &medical.UserInfo{
  62. UserId: rand.Int63n(100000000000),
  63. Mail: "qqq.com",
  64. Phone: "13111111111",
  65. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  66. Position: "经理",
  67. Department: "公关",
  68. EntName: "测试企业",
  69. OperationType: "add",
  70. Appid: "10000",
  71. },
  72. }},
  73. {
  74. name: "用户认证信息保存-用户已认证",
  75. args: args{
  76. &medical.UserInfo{
  77. UserId: 36685456029,
  78. Mail: "qqq.com",
  79. Phone: "13111111111",
  80. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  81. Position: "经理",
  82. Department: "公关",
  83. EntName: "测试企业",
  84. OperationType: "add",
  85. Appid: "10000",
  86. },
  87. }},
  88. {
  89. name: "用户认证信息修改",
  90. args: args{
  91. &medical.UserInfo{
  92. UserId: 36685456029,
  93. Mail: "qqq.com",
  94. Phone: "13111111111",
  95. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  96. Position: "经理",
  97. Department: "公关",
  98. EntName: "测试企业",
  99. OperationType: "update",
  100. Appid: "10000",
  101. },
  102. },
  103. },
  104. {
  105. name: "用户认证信息修改-未认证",
  106. args: args{
  107. &medical.UserInfo{
  108. UserId: 11111,
  109. Mail: "qqq.com",
  110. Phone: "13111111111",
  111. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  112. Position: "经理",
  113. Department: "公关",
  114. EntName: "测试企业",
  115. OperationType: "update",
  116. Appid: "10000",
  117. },
  118. },
  119. },
  120. }
  121. for _, tt := range tests {
  122. t.Run(tt.name, func(t *testing.T) {
  123. b := AuthService{}
  124. got, got1 := b.UserAuthInfoSave(tt.args.in)
  125. if got != tt.want {
  126. t.Errorf("UserAuthInfoSave() got = %v, want %v", got, tt.want)
  127. }
  128. if got1 != tt.want1 {
  129. t.Errorf("UserAuthInfoSave() got1 = %v, want %v", got1, tt.want1)
  130. }
  131. })
  132. }
  133. }