claim_test.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package service
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
  6. "fmt"
  7. "testing"
  8. )
  9. // 认领
  10. func TestEntClaimService_Claim(t *testing.T) {
  11. type args struct {
  12. data *entity.EntClaim
  13. }
  14. tests := []struct {
  15. name string
  16. args args
  17. want bool
  18. }{
  19. {"认领医疗机构", args{
  20. data: &entity.EntClaim{UserId: 1, AppId: "10000", EntId: "1122", EntName: "877", Status: entity.StatusClaimed, Type: entity.TypeInstitution, Address: "2223", EstablishDate: "2022", RegisterCapital: "dd", Phone: "18238182402", CreateTime: "2022-08-19 15:08:00"},
  21. }, true,
  22. },
  23. {"认领医疗机构-2", args{
  24. data: &entity.EntClaim{UserId: 2, AppId: "10000", EntId: "7", EntName: "8757", Status: entity.StatusClaimed, Type: entity.TypeDistributor, Address: "2223", EstablishDate: "2022", RegisterCapital: "dd", Phone: "18238182402", CreateTime: "2022-08-19 15:08:00"},
  25. }, true,
  26. },
  27. }
  28. for _, tt := range tests {
  29. t.Run(tt.name, func(t *testing.T) {
  30. if got := EntClaimSrv.Claim(tt.args.data); got != tt.want {
  31. t.Errorf("Claim() = %v, want %v", got, tt.want)
  32. }
  33. })
  34. }
  35. }
  36. // 我认领的经销商的列表
  37. func TestEntClaimService_DistributorList(t *testing.T) {
  38. type args struct {
  39. userId int
  40. appId string
  41. page int
  42. pageSize int
  43. }
  44. tests := []struct {
  45. name string
  46. args args
  47. want *[]map[string]interface{}
  48. }{
  49. {
  50. name: "我认领的经销商", args: args{userId: 1, appId: "10000", page: 0, pageSize: 10}, want: nil,
  51. },
  52. {
  53. name: "我认领的经销商-2", args: args{userId: 8, appId: "10000", page: 0, pageSize: 10}, want: nil,
  54. },
  55. }
  56. for _, tt := range tests {
  57. t.Run(tt.name, func(t *testing.T) {
  58. got, total := EntClaimSrv.DistributorList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize)
  59. fmt.Println(got, total)
  60. t.Log(got, total)
  61. })
  62. }
  63. }
  64. // 我认领的机构列表
  65. func TestEntClaimService_InstitutionList(t *testing.T) {
  66. type args struct {
  67. userId int
  68. appId string
  69. page int
  70. pageSize int
  71. }
  72. tests := []struct {
  73. name string
  74. args args
  75. want *[]map[string]interface{}
  76. }{
  77. {
  78. name: "我认领的医疗机构", args: args{userId: 1, appId: "10000", page: 0, pageSize: 10}, want: nil,
  79. },
  80. {
  81. name: "我认领的医疗机构-2", args: args{userId: 3, appId: "10000", page: 0, pageSize: 10}, want: nil,
  82. },
  83. }
  84. for _, tt := range tests {
  85. t.Run(tt.name, func(t *testing.T) {
  86. got, total := EntClaimSrv.InstitutionList(tt.args.userId, tt.args.appId, tt.args.page, tt.args.pageSize)
  87. t.Log(got, total)
  88. })
  89. }
  90. }
  91. // 是否认领
  92. func TestEntClaimService_IsClaimed(t *testing.T) {
  93. type args struct {
  94. userId int
  95. appId string
  96. entId string
  97. typeCode int
  98. }
  99. tests := []struct {
  100. name string
  101. args args
  102. want bool
  103. }{
  104. {"是否认领", args{userId: 1, typeCode: 1, entId: "1", appId: "10000"}, true},
  105. }
  106. for _, tt := range tests {
  107. t.Run(tt.name, func(t *testing.T) {
  108. if got := EntClaimSrv.IsClaimed(tt.args.userId, tt.args.appId, tt.args.entId, tt.args.typeCode); got != tt.want {
  109. t.Errorf("IsClaimed() = %v, want %v", got, tt.want)
  110. }
  111. })
  112. }
  113. }
  114. // 取消认领
  115. func TestEntClaimService_Unclaimed(t *testing.T) {
  116. type args struct {
  117. id int
  118. userId int
  119. }
  120. tests := []struct {
  121. name string
  122. args args
  123. want bool
  124. }{
  125. {
  126. "取消认领", args{userId: 1, id: 2}, true,
  127. },
  128. {
  129. "取消认领-2", args{userId: 100, id: 2}, false,
  130. },
  131. {
  132. "取消认领-3", args{userId: 100, id: 900009}, false,
  133. },
  134. }
  135. for _, tt := range tests {
  136. t.Run(tt.name, func(t *testing.T) {
  137. if got := EntClaimSrv.Unclaimed(tt.args.id, tt.args.userId); got != tt.want {
  138. t.Errorf("Unclaimed() = %v, want %v", got, tt.want)
  139. }
  140. })
  141. }
  142. }
  143. // 获取企业基本信息
  144. func TestEntClaimService_GetInstitution(t *testing.T) {
  145. type args struct {
  146. id string
  147. }
  148. tests := []struct {
  149. name string
  150. args args
  151. want *map[string]interface{}
  152. }{
  153. {
  154. "获取企业基本信息", args{id: ""}, nil,
  155. },
  156. }
  157. for _, tt := range tests {
  158. t.Run(tt.name, func(t *testing.T) {
  159. got := EntClaimSrv.GetInstitution(tt.args.id)
  160. t.Log(got)
  161. })
  162. }
  163. }
  164. func TestName(t *testing.T) {
  165. s := encrypt.SE.Encode2Hex(common.ObjToString("90009"))
  166. fmt.Print(s)
  167. }