AuthService_test.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. if got := authService.UserAuthInfo(tt.args.in); !reflect.DeepEqual(got, tt.want) {
  41. t.Errorf("UserAuthInfo() = %v, want %v", got, tt.want)
  42. }
  43. })
  44. }
  45. }
  46. func TestAuthService_UserAuthInfoSave(t *testing.T) {
  47. type args struct {
  48. in *medical.UserInfo
  49. }
  50. tests := []struct {
  51. name string
  52. args args
  53. want bool
  54. want1 string
  55. }{
  56. // TODO: Add test cases.
  57. {
  58. name: "用户认证信息保存",
  59. args: args{
  60. &medical.UserInfo{
  61. UserId: rand.Int63n(100000000000),
  62. Mail: "qqq.com",
  63. Phone: "13111111111",
  64. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  65. Position: "经理",
  66. Department: "公关",
  67. EntName: "测试企业",
  68. OperationType: "add",
  69. Appid: "10000",
  70. },
  71. }},
  72. {
  73. name: "用户认证信息保存-用户已认证",
  74. args: args{
  75. &medical.UserInfo{
  76. UserId: 36685456029,
  77. Mail: "qqq.com",
  78. Phone: "13111111111",
  79. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  80. Position: "经理",
  81. Department: "公关",
  82. EntName: "测试企业",
  83. OperationType: "add",
  84. Appid: "10000",
  85. },
  86. }},
  87. {
  88. name: "用户认证信息修改",
  89. args: args{
  90. &medical.UserInfo{
  91. UserId: 36685456029,
  92. Mail: "qqq.com",
  93. Phone: "13111111111",
  94. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  95. Position: "经理",
  96. Department: "公关",
  97. EntName: "测试企业",
  98. OperationType: "update",
  99. Appid: "10000",
  100. },
  101. },
  102. },
  103. {
  104. name: "用户未认证,不可修改",
  105. args: args{
  106. &medical.UserInfo{
  107. UserId: 11,
  108. Mail: "qqq.com",
  109. Phone: "13111111111",
  110. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  111. Position: "经理",
  112. Department: "公关",
  113. EntName: "测试企业",
  114. OperationType: "update",
  115. Appid: "10000",
  116. },
  117. },
  118. want1: "用户未认证,不可修改",
  119. },
  120. {
  121. name: "用户认证信息修改-未认证",
  122. args: args{
  123. &medical.UserInfo{
  124. UserId: 11111,
  125. Mail: "qqq.com",
  126. Phone: "13111111111",
  127. Name: fmt.Sprintf("用户%d", rand.Int63n(1000)),
  128. Position: "经理",
  129. Department: "公关",
  130. EntName: "测试企业",
  131. OperationType: "update",
  132. Appid: "10000",
  133. },
  134. },
  135. },
  136. }
  137. for _, tt := range tests {
  138. t.Run(tt.name, func(t *testing.T) {
  139. got, got1 := authService.UserAuthInfoSave(tt.args.in)
  140. if got != tt.want {
  141. t.Errorf("UserAuthInfoSave() got = %v, want %v", got, tt.want)
  142. }
  143. if got1 != tt.want1 {
  144. t.Errorf("UserAuthInfoSave() got1 = %v, want %v", got1, tt.want1)
  145. }
  146. })
  147. }
  148. }