main_test.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. package archives_test
  2. import (
  3. "testing"
  4. "gogs.uu.mdfitnesscao.com/cuiguohai/sdk"
  5. "gogs.uu.mdfitnesscao.com/cuiguohai/sdk/archives"
  6. "gogs.uu.mdfitnesscao.com/cuiguohai/sdk/utils"
  7. )
  8. func TestList(t *testing.T) {
  9. t.Run("test", func(t *testing.T) {
  10. sdk.InitConfig(&sdk.ClientConfig{
  11. ApiDomain: "https://mcapi.mdfitnesscao.com",
  12. AppDebug: true,
  13. })
  14. response, err := archives.Detail("B8JB6J0d", "", "")
  15. list := response.Data.Detail
  16. if err != nil {
  17. t.Errorf("err: %v", err)
  18. }
  19. t.Logf("list: %v", list)
  20. })
  21. }
  22. func TestGetArchivesDataListByDate(t *testing.T) {
  23. t.Run("test", func(t *testing.T) {
  24. sdk.InitConfig(&sdk.ClientConfig{
  25. ApiDomain: "https://mcapi.mdfitnesscao.com",
  26. AppDebug: true,
  27. })
  28. response, err := archives.ListUpdatedArchivesDataByDate("2023-09-15", "aaaaa")
  29. list := response.Data.List
  30. if err != nil {
  31. t.Errorf("err: %v", err)
  32. }
  33. t.Logf("list: %v", utils.JsonEncode(list))
  34. })
  35. }
  36. func TestGetArchivesListByDate(t *testing.T) {
  37. t.Run("test", func(t *testing.T) {
  38. sdk.InitConfig(&sdk.ClientConfig{
  39. ApiDomain: "https://mcapi.mdfitnesscao.com",
  40. AppDebug: true,
  41. })
  42. response, err := archives.ListUpdatedArchivesByDate("2023-09-15")
  43. list := response.Data.List
  44. if err != nil {
  45. t.Errorf("err: %v", err)
  46. }
  47. t.Logf("lista :%v", list)
  48. })
  49. }
  50. func TestCheckIsArchivesFamily(t *testing.T) {
  51. t.Run("test", func(t *testing.T) {
  52. sdk.InitConfig(&sdk.ClientConfig{
  53. ApiDomain: "https://mcapi.mdfitnesscao.com",
  54. AppDebug: true,
  55. })
  56. response, _ := archives.CheckIsArchivesFamily([]string{
  57. "pWJM3jrG",
  58. "Ydm62mB8",
  59. })
  60. isFamily := response.Data["isFamily"]
  61. t.Logf("lista :%v", isFamily)
  62. })
  63. }
  64. func TestGetArchivesListByIds(t *testing.T) {
  65. t.Run("test", func(t *testing.T) {
  66. sdk.InitConfig(&sdk.ClientConfig{
  67. ApiDomain: "https://mcapi.mdfitnesscao.com",
  68. AppDebug: true,
  69. })
  70. response, err := archives.ListArchivesById([]string{
  71. "Ydm660mB", "8VjdwPm4", "123",
  72. }, "", "", 0)
  73. list := response.Data.List
  74. if err != nil {
  75. t.Errorf("err: %v", err)
  76. }
  77. t.Logf("lista :%v", list)
  78. })
  79. }
  80. func TestCreateArchives(t *testing.T) {
  81. t.Run("test", func(t *testing.T) {
  82. sdk.InitConfig(&sdk.ClientConfig{
  83. ApiDomain: "https://mcapi.mdfitnesscao.com",
  84. AppDebug: true,
  85. })
  86. response, err := archives.Create(&sdk.Archives{
  87. Name: "哈哈哈哈",
  88. Gender: 1,
  89. Birthday: "2023-09-15",
  90. Accounts: []*sdk.Account{
  91. {
  92. Account: "18523523535",
  93. Type: 1,
  94. },
  95. },
  96. })
  97. if err != nil {
  98. t.Errorf("err: %v", err)
  99. }
  100. t.Logf("response :%v", response)
  101. })
  102. }
  103. func TestCreateArchivesOrFindByAccount(t *testing.T) {
  104. t.Run("test", func(t *testing.T) {
  105. sdk.InitConfig(&sdk.ClientConfig{
  106. ApiDomain: "https://mcapi.mdfitnesscao.com",
  107. AppDebug: true,
  108. })
  109. response, err := archives.CreateOrFindByAccount(&sdk.Archives{
  110. Name: "哈哈哈哈12",
  111. Gender: 1,
  112. Birthday: "2023-09-15",
  113. Accounts: []*sdk.Account{
  114. {
  115. Account: "zhangsan_hhhh",
  116. Type: 3,
  117. },
  118. },
  119. }, &sdk.ArchivesAttachForm{
  120. ChannelId: 3,
  121. }, &sdk.Account{
  122. Account: "zhangsan_hhhh",
  123. Type: 3,
  124. })
  125. if err != nil {
  126. t.Errorf("err: %v", err)
  127. }
  128. t.Logf("response :%v", response)
  129. })
  130. }
  131. func TestTriggerArchivesMedicalReport(t *testing.T) {
  132. t.Run("test", func(t *testing.T) {
  133. sdk.InitConfig(&sdk.ClientConfig{
  134. ApiDomain: "https://mcapi.mdfitnesscao.com",
  135. AppDebug: true,
  136. })
  137. response, err := archives.TriggerArchivesMedicalReport("WNm0dm07")
  138. if err != nil {
  139. t.Errorf("err: %v", err)
  140. }
  141. t.Logf("response :%v", response)
  142. })
  143. }
  144. func TestGetArchivesValues(t *testing.T) {
  145. t.Run("test", func(t *testing.T) {
  146. sdk.InitConfig(&sdk.ClientConfig{
  147. ApiDomain: "https://mcapi.mdfitnesscao.com",
  148. AppDebug: true,
  149. })
  150. response, err := archives.GetArchivesValues("yojkwRjZ", []string{"medicationStatus"})
  151. if err != nil {
  152. t.Errorf("err: %v", err)
  153. }
  154. t.Logf("response :%v", response)
  155. })
  156. }
  157. func TestPaginateArchives(t *testing.T) {
  158. t.Run("test", func(t *testing.T) {
  159. sdk.InitConfig(&sdk.ClientConfig{
  160. ApiDomain: "https://mcapi.mdfitnesscao.com",
  161. AppDebug: true,
  162. })
  163. response, err := archives.PaginateArchives(&sdk.ArchivesPaginateQuery{
  164. Page: 1,
  165. PageSize: 100,
  166. RegistMechanismId: "Xwlg97rP",
  167. AgeEnd: 200,
  168. }, "", "")
  169. list := response.Data.List
  170. if err != nil {
  171. t.Errorf("err: %v", err)
  172. }
  173. t.Logf("list :%v", list)
  174. })
  175. }
  176. func TestListArchivesIds(t *testing.T) {
  177. t.Run("test", func(t *testing.T) {
  178. sdk.InitConfig(&sdk.ClientConfig{
  179. ApiDomain: "https://mcapi.mdfitnesscao.com",
  180. AppDebug: true,
  181. })
  182. response, err := archives.ListArchivesIds(nil, "Xwlg97rP", "yEw98oR0")
  183. list := response.Data.List
  184. if err != nil {
  185. t.Errorf("err: %v", err)
  186. }
  187. t.Logf("list :%v", list)
  188. })
  189. }
  190. func TestGetValidArchivesIdsForMechanism(t *testing.T) {
  191. t.Run("test", func(t *testing.T) {
  192. sdk.InitConfig(&sdk.ClientConfig{
  193. ApiDomain: "https://mcapi.mdfitnesscao.com",
  194. AppDebug: true,
  195. })
  196. response, _ := archives.GetValidArchivesIdsForMechanism([]string{
  197. "pWJM3jrG",
  198. "Ydm62mB8",
  199. }, "M57wVRNZ")
  200. isFamily := response.Data.List
  201. t.Logf("lista :%v", isFamily)
  202. })
  203. }
  204. func TestListChannelByIds(t *testing.T) {
  205. t.Run("test", func(t *testing.T) {
  206. sdk.InitConfig(&sdk.ClientConfig{
  207. ApiDomain: "https://mcapi.mdfitnesscao.com",
  208. AppDebug: true,
  209. })
  210. response, _ := archives.ListChannelByIds([]int64{
  211. 3,
  212. }, "")
  213. isFamily := response.Data.List
  214. t.Logf("list :%v", isFamily)
  215. })
  216. }