tree_test.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. package service
  2. import (
  3. "testing"
  4. "go-common/app/admin/ep/merlin/model"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. var (
  8. sessionID = "37556f106c8eb7b495c7986e6339fabc"
  9. )
  10. func Test_Tree(t *testing.T) {
  11. Convey("test TreeSon", t, func() {
  12. treeURI := s.c.ServiceTree.Host + "/v1/node/extree" + "/bilibili.test.benchmark.jemeter"
  13. httpMock("GET", treeURI).Reply(200).JSON(getTreeSonJSONResponse)
  14. err := s.VerifyTreeContainerNode(c, sessionID, &model.TreeNode{BusinessUnit: "test", Project: "benchmark", App: "jemeter"})
  15. So(err, ShouldBeNil)
  16. })
  17. }
  18. var (
  19. getTreeSonJSONResponse = `{
  20. "code": 90000,
  21. "data": {
  22. "dev": {
  23. "id": 19024,
  24. "name": "dev",
  25. "alias": "研发环境",
  26. "uuid": "",
  27. "type": 5,
  28. "path": "bilibili.test.benchmark.jemeter.dev",
  29. "tags": {},
  30. "children": {
  31. "containers": {
  32. "id": 19029,
  33. "name": "containers",
  34. "alias": "容器",
  35. "uuid": "",
  36. "type": 6,
  37. "path": "bilibili.test.benchmark.jemeter.dev.containers",
  38. "tags": {},
  39. "children": null
  40. },
  41. "servers": {
  42. "id": 19028,
  43. "name": "servers",
  44. "alias": "物理机/虚机",
  45. "uuid": "",
  46. "type": 6,
  47. "path": "bilibili.test.benchmark.jemeter.dev.servers",
  48. "tags": {},
  49. "children": null
  50. }
  51. }
  52. },
  53. "fat1": {
  54. "id": 19023,
  55. "name": "fat1",
  56. "alias": "功能环境1",
  57. "uuid": "",
  58. "type": 5,
  59. "path": "bilibili.test.benchmark.jemeter.fat1",
  60. "tags": {},
  61. "children": {
  62. "containers": {
  63. "id": 19031,
  64. "name": "containers",
  65. "alias": "容器",
  66. "uuid": "",
  67. "type": 6,
  68. "path": "bilibili.test.benchmark.jemeter.fat1.containers",
  69. "tags": {},
  70. "children": null
  71. },
  72. "servers": {
  73. "id": 19030,
  74. "name": "servers",
  75. "alias": "物理机/虚机",
  76. "uuid": "",
  77. "type": 6,
  78. "path": "bilibili.test.benchmark.jemeter.fat1.servers",
  79. "tags": {},
  80. "children": null
  81. }
  82. }
  83. },
  84. "pre": {
  85. "id": 19025,
  86. "name": "pre",
  87. "alias": "预发布环境",
  88. "uuid": "",
  89. "type": 5,
  90. "path": "bilibili.test.benchmark.jemeter.pre",
  91. "tags": {},
  92. "children": {
  93. "containers": {
  94. "id": 19033,
  95. "name": "containers",
  96. "alias": "容器",
  97. "uuid": "",
  98. "type": 6,
  99. "path": "bilibili.test.benchmark.jemeter.pre.containers",
  100. "tags": {},
  101. "children": null
  102. },
  103. "servers": {
  104. "id": 19032,
  105. "name": "servers",
  106. "alias": "物理机/虚机",
  107. "uuid": "",
  108. "type": 6,
  109. "path": "bilibili.test.benchmark.jemeter.pre.servers",
  110. "tags": {},
  111. "children": null
  112. }
  113. }
  114. },
  115. "prod": {
  116. "id": 19026,
  117. "name": "prod",
  118. "alias": "生产环境",
  119. "uuid": "",
  120. "type": 5,
  121. "path": "bilibili.test.benchmark.jemeter.prod",
  122. "tags": {},
  123. "children": {
  124. "containers": {
  125. "id": 19035,
  126. "name": "containers",
  127. "alias": "容器",
  128. "uuid": "",
  129. "type": 6,
  130. "path": "bilibili.test.benchmark.jemeter.prod.containers",
  131. "tags": {},
  132. "children": null
  133. },
  134. "servers": {
  135. "id": 19034,
  136. "name": "servers",
  137. "alias": "物理机/虚机",
  138. "uuid": "",
  139. "type": 6,
  140. "path": "bilibili.test.benchmark.jemeter.prod.servers",
  141. "tags": {},
  142. "children": null
  143. }
  144. }
  145. },
  146. "uat": {
  147. "id": 19027,
  148. "name": "uat",
  149. "alias": "集成环境",
  150. "uuid": "",
  151. "type": 5,
  152. "path": "bilibili.test.benchmark.jemeter.uat",
  153. "tags": {},
  154. "children": {
  155. "containers": {
  156. "id": 19037,
  157. "name": "containers",
  158. "alias": "容器",
  159. "uuid": "",
  160. "type": 6,
  161. "path": "bilibili.test.benchmark.jemeter.uat.containers",
  162. "tags": {},
  163. "children": null
  164. },
  165. "servers": {
  166. "id": 19036,
  167. "name": "servers",
  168. "alias": "物理机/虚机",
  169. "uuid": "",
  170. "type": 6,
  171. "path": "bilibili.test.benchmark.jemeter.uat.servers",
  172. "tags": {},
  173. "children": null
  174. }
  175. }
  176. }
  177. },
  178. "message": "success",
  179. "status": 200
  180. }`
  181. )