testcase.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. package testdata
  2. import _ "embed"
  3. var (
  4. //go:embed unformat.api
  5. unformatApi string
  6. //go:embed kotlin.api
  7. kotlinApi string
  8. //go:embed user.sql
  9. userSql string
  10. list = Files{
  11. {
  12. IsDir: true,
  13. Path: "version",
  14. Cmd: "goctl --version",
  15. },
  16. {
  17. IsDir: true,
  18. Path: "api/sample_file/local",
  19. Cmd: "goctl api --o sample.api",
  20. },
  21. {
  22. IsDir: true,
  23. Path: "api/sample_file/local/assign",
  24. Cmd: "goctl api --o=sample.api",
  25. },
  26. {
  27. IsDir: true,
  28. Path: "api/sample_file/local/assign/shorthand",
  29. Cmd: "goctl api -o=sample.api",
  30. },
  31. {
  32. IsDir: true,
  33. Path: "api/sample_file/remote",
  34. Cmd: "goctl api --o sample.api --remote https://github.com/wuntsong-org/go-zero-plus-template --branch main",
  35. },
  36. {
  37. IsDir: true,
  38. Path: "api/sample_file/remote/shorthand",
  39. Cmd: "goctl api -o sample.api -remote https://github.com/wuntsong-org/go-zero-plus-template -branch main",
  40. },
  41. {
  42. IsDir: true,
  43. Path: "api/sample_file/remote/assign",
  44. Cmd: "goctl api --o=sample.api --remote https://github.com/wuntsong-org/go-zero-plus-template --branch=main",
  45. },
  46. {
  47. IsDir: true,
  48. Path: "api/sample_file/remote/assign/shorthand",
  49. Cmd: "goctl api -o=sample.api -remote https://github.com/wuntsong-org/go-zero-plus-template -branch=main",
  50. },
  51. {
  52. IsDir: true,
  53. Path: "api/dart/legacy/true",
  54. Cmd: "goctl api --o sample.api && goctl api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
  55. },
  56. {
  57. IsDir: true,
  58. Path: "api/dart/legacy/true/shorthand",
  59. Cmd: "goctl api -o sample.api && goctl api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
  60. },
  61. {
  62. IsDir: true,
  63. Path: "api/dart/legacy/true/assign",
  64. Cmd: "goctl api --o=sample.api && goctl api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
  65. },
  66. {
  67. IsDir: true,
  68. Path: "api/dart/legacy/true/assign/shorthand",
  69. Cmd: "goctl api -o=sample.api && goctl api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
  70. },
  71. {
  72. IsDir: true,
  73. Path: "api/dart/legacy/false",
  74. Cmd: "goctl api --o sample.api && goctl api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
  75. },
  76. {
  77. IsDir: true,
  78. Path: "api/dart/legacy/false/shorthand",
  79. Cmd: "goctl api -o sample.api && goctl api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
  80. },
  81. {
  82. IsDir: true,
  83. Path: "api/dart/legacy/false/assign",
  84. Cmd: "goctl api --o=sample.api && goctl api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
  85. },
  86. {
  87. IsDir: true,
  88. Path: "api/dart/legacy/false/assign/shorthand",
  89. Cmd: "goctl api -o=sample.api && goctl api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
  90. },
  91. {
  92. IsDir: true,
  93. Path: "api/doc",
  94. Cmd: "goctl api --o sample.api && goctl api doc --dir . --o .",
  95. },
  96. {
  97. IsDir: true,
  98. Path: "api/doc/shorthand",
  99. Cmd: "goctl api -o sample.api && goctl api doc -dir . -o .",
  100. },
  101. {
  102. IsDir: true,
  103. Path: "api/doc/assign",
  104. Cmd: "goctl api --o=sample.api && goctl api doc --dir=. --o=.",
  105. },
  106. {
  107. IsDir: true,
  108. Path: "api/doc/assign/shorthand",
  109. Cmd: "goctl api -o=sample.api && goctl api doc -dir=. -o=.",
  110. },
  111. {
  112. Path: "api/format/unformat.api",
  113. Content: unformatApi,
  114. Cmd: "goctl api format --dir . --iu",
  115. },
  116. {
  117. Path: "api/format/shorthand/unformat.api",
  118. Content: unformatApi,
  119. Cmd: "goctl api format -dir . -iu",
  120. },
  121. {
  122. Path: "api/format/assign/unformat.api",
  123. Content: unformatApi,
  124. Cmd: "goctl api format --dir=. --iu",
  125. },
  126. {
  127. Path: "api/format/assign/shorthand/unformat.api",
  128. Content: unformatApi,
  129. Cmd: "goctl api format -dir=. -iu",
  130. },
  131. {
  132. IsDir: true,
  133. Path: "api/go/style/default",
  134. Cmd: "goctl api --o sample.api && goctl api go --api sample.api --dir .",
  135. },
  136. {
  137. IsDir: true,
  138. Path: "api/go/style/default/shorthand",
  139. Cmd: "goctl api -o sample.api && goctl api go -api sample.api -dir .",
  140. },
  141. {
  142. IsDir: true,
  143. Path: "api/go/style/assign/default",
  144. Cmd: "goctl api --o=sample.api && goctl api go --api=sample.api --dir=.",
  145. },
  146. {
  147. IsDir: true,
  148. Path: "api/go/style/assign/default/shorthand",
  149. Cmd: "goctl api -o=sample.api && goctl api go -api=sample.api -dir=.",
  150. },
  151. {
  152. IsDir: true,
  153. Path: "api/go/style/goZero",
  154. Cmd: "goctl api --o sample.api && goctl api go --api sample.api --dir . --style goZero",
  155. },
  156. {
  157. IsDir: true,
  158. Path: "api/go/style/goZero/shorthand",
  159. Cmd: "goctl api -o sample.api && goctl api go -api sample.api -dir . -style goZero",
  160. },
  161. {
  162. IsDir: true,
  163. Path: "api/go/style/goZero/assign",
  164. Cmd: "goctl api --o=sample.api && goctl api go --api=sample.api --dir=. --style=goZero",
  165. },
  166. {
  167. IsDir: true,
  168. Path: "api/go/style/goZero/assign/shorthand",
  169. Cmd: "goctl api -o=sample.api && goctl api go -api=sample.api -dir=. -style=goZero",
  170. },
  171. {
  172. IsDir: true,
  173. Path: "api/java",
  174. Cmd: "goctl api --o sample.api && goctl api java --api sample.api --dir .",
  175. },
  176. {
  177. IsDir: true,
  178. Path: "api/java/shorthand",
  179. Cmd: "goctl api -o sample.api && goctl api java -api sample.api -dir .",
  180. },
  181. {
  182. IsDir: true,
  183. Path: "api/java/assign",
  184. Cmd: "goctl api --o=sample.api && goctl api java --api=sample.api --dir=.",
  185. },
  186. {
  187. IsDir: true,
  188. Path: "api/java/shorthand/assign",
  189. Cmd: "goctl api -o=sample.api && goctl api java -api=sample.api -dir=.",
  190. },
  191. {
  192. IsDir: true,
  193. Path: "api/new/style/default",
  194. Cmd: "goctl api new greet",
  195. },
  196. {
  197. IsDir: true,
  198. Path: "api/new/style/goZero",
  199. Cmd: "goctl api new greet --style goZero",
  200. },
  201. {
  202. IsDir: true,
  203. Path: "api/new/style/goZero/assign",
  204. Cmd: "goctl api new greet --style=goZero",
  205. },
  206. {
  207. IsDir: true,
  208. Path: "api/new/style/goZero/shorthand",
  209. Cmd: "goctl api new greet -style goZero",
  210. },
  211. {
  212. IsDir: true,
  213. Path: "api/new/style/goZero/shorthand/assign",
  214. Cmd: "goctl api new greet -style=goZero",
  215. },
  216. {
  217. IsDir: true,
  218. Path: "api/ts",
  219. Cmd: "goctl api --o sample.api && goctl api ts --api sample.api --dir . --unwrap --webapi .",
  220. },
  221. {
  222. IsDir: true,
  223. Path: "api/ts/shorthand",
  224. Cmd: "goctl api -o sample.api && goctl api ts -api sample.api -dir . -unwrap -webapi .",
  225. },
  226. {
  227. IsDir: true,
  228. Path: "api/ts/assign",
  229. Cmd: "goctl api --o=sample.api && goctl api ts --api=sample.api --dir=. --unwrap --webapi=.",
  230. },
  231. {
  232. IsDir: true,
  233. Path: "api/ts/shorthand/assign",
  234. Cmd: "goctl api -o=sample.api && goctl api ts -api=sample.api -dir=. -unwrap -webapi=.",
  235. },
  236. {
  237. IsDir: true,
  238. Path: "api/validate",
  239. Cmd: "goctl api --o sample.api && goctl api validate --api sample.api",
  240. },
  241. {
  242. IsDir: true,
  243. Path: "api/validate/shorthand",
  244. Cmd: "goctl api -o sample.api && goctl api validate -api sample.api",
  245. },
  246. {
  247. IsDir: true,
  248. Path: "api/validate/assign",
  249. Cmd: "goctl api --o=sample.api && goctl api validate --api=sample.api",
  250. },
  251. {
  252. IsDir: true,
  253. Path: "api/validate/shorthand/assign",
  254. Cmd: "goctl api -o=sample.api && goctl api validate -api=sample.api",
  255. },
  256. {
  257. IsDir: true,
  258. Path: "env/show",
  259. Cmd: "goctl env > env.txt",
  260. },
  261. {
  262. IsDir: true,
  263. Path: "env/check",
  264. Cmd: "goctl env check -f -v",
  265. },
  266. {
  267. IsDir: true,
  268. Path: "env/install",
  269. Cmd: "goctl env install -v",
  270. },
  271. {
  272. IsDir: true,
  273. Path: "kube",
  274. Cmd: "goctl kube deploy --image alpine --name foo --namespace foo --o foo.yaml --port 8888",
  275. },
  276. {
  277. IsDir: true,
  278. Path: "kube/shorthand",
  279. Cmd: "goctl kube deploy -image alpine -name foo -namespace foo -o foo.yaml -port 8888",
  280. },
  281. {
  282. IsDir: true,
  283. Path: "kube/assign",
  284. Cmd: "goctl kube deploy --image=alpine --name=foo --namespace=foo --o=foo.yaml --port=8888",
  285. },
  286. {
  287. IsDir: true,
  288. Path: "kube/shorthand/assign",
  289. Cmd: "goctl kube deploy -image=alpine -name=foo -namespace=foo -o=foo.yaml -port=8888",
  290. },
  291. {
  292. IsDir: true,
  293. Path: "model/mongo/cache",
  294. Cmd: "goctl model mongo --dir . --type user --style goZero -c",
  295. },
  296. {
  297. IsDir: true,
  298. Path: "model/mongo/cache/shorthand",
  299. Cmd: "goctl model mongo -dir . -type user -style goZero -c",
  300. },
  301. {
  302. IsDir: true,
  303. Path: "model/mongo/cache/assign",
  304. Cmd: "goctl model mongo --dir=. --type=user --style=goZero -c",
  305. },
  306. {
  307. IsDir: true,
  308. Path: "model/mongo/cache/shorthand/assign",
  309. Cmd: "goctl model mongo -dir=. -type=user -style=goZero -c",
  310. },
  311. {
  312. IsDir: true,
  313. Path: "model/mongo/nocache",
  314. Cmd: "goctl model mongo --dir . --type user",
  315. },
  316. {
  317. IsDir: true,
  318. Path: "model/mongo/nocache/shorthand",
  319. Cmd: "goctl model mongo -dir . -type user",
  320. },
  321. {
  322. IsDir: true,
  323. Path: "model/mongo/nocache/assign",
  324. Cmd: "goctl model mongo --dir=. --type=user",
  325. },
  326. {
  327. IsDir: true,
  328. Path: "model/mongo/nocache/shorthand/assign",
  329. Cmd: "goctl model mongo -dir=. -type=user",
  330. },
  331. {
  332. Content: userSql,
  333. Path: "model/mysql/ddl/user.sql",
  334. Cmd: "goctl model mysql ddl --database user --dir cache --src user.sql -c",
  335. },
  336. {
  337. Content: userSql,
  338. Path: "model/mysql/ddl/shorthand/user.sql",
  339. Cmd: "goctl model mysql ddl -database user -dir cache -src user.sql -c",
  340. },
  341. {
  342. Content: userSql,
  343. Path: "model/mysql/ddl/assign/user.sql",
  344. Cmd: "goctl model mysql ddl --database=user --dir=cache --src=user.sql -c",
  345. },
  346. {
  347. Content: userSql,
  348. Path: "model/mysql/ddl/shorthand/assign/user.sql",
  349. Cmd: "goctl model mysql ddl -database=user -dir=cache -src=user.sql -c",
  350. },
  351. {
  352. Content: userSql,
  353. Path: "model/mysql/ddl/user.sql",
  354. Cmd: "goctl model mysql ddl --database user --dir nocache --src user.sql",
  355. },
  356. {
  357. Content: userSql,
  358. Path: "model/mysql/ddl/shorthand/user.sql",
  359. Cmd: "goctl model mysql ddl -database user -dir nocache -src user.sql",
  360. },
  361. {
  362. Content: userSql,
  363. Path: "model/mysql/ddl/assign/user.sql",
  364. Cmd: "goctl model mysql ddl --database=user --dir=nocache --src=user.sql",
  365. },
  366. {
  367. Content: userSql,
  368. Path: "model/mysql/ddl/shorthand/assign/user.sql",
  369. Cmd: "goctl model mysql ddl -database=user -dir=nocache -src=user.sql",
  370. },
  371. {
  372. IsDir: true,
  373. Path: "model/mysql/datasource",
  374. Cmd: `goctl model mysql datasource --url $DSN --dir cache --table "*" -c`,
  375. },
  376. {
  377. IsDir: true,
  378. Path: "model/mysql/datasource/shorthand",
  379. Cmd: `goctl model mysql datasource -url $DSN -dir cache -table "*" -c`,
  380. },
  381. {
  382. IsDir: true,
  383. Path: "model/mysql/datasource/shorthand2",
  384. Cmd: `goctl model mysql datasource -url $DSN -dir cache -t "*" -c`,
  385. },
  386. {
  387. IsDir: true,
  388. Path: "model/mysql/datasource/assign",
  389. Cmd: `goctl model mysql datasource --url=$DSN --dir=cache --table="*" -c`,
  390. },
  391. {
  392. IsDir: true,
  393. Path: "model/mysql/datasource/shorthand/assign",
  394. Cmd: `goctl model mysql datasource -url=$DSN -dir=cache -table="*" -c`,
  395. },
  396. {
  397. IsDir: true,
  398. Path: "model/mysql/datasource/shorthand2/assign",
  399. Cmd: `goctl model mysql datasource -url=$DSN -dir=cache -t="*" -c`,
  400. },
  401. {
  402. IsDir: true,
  403. Path: "model/mysql/datasource",
  404. Cmd: `goctl model mysql datasource --url $DSN --dir nocache --table "*" -c`,
  405. },
  406. {
  407. IsDir: true,
  408. Path: "model/mysql/datasource/shorthand",
  409. Cmd: `goctl model mysql datasource -url $DSN -dir nocache -table "*" -c`,
  410. },
  411. {
  412. IsDir: true,
  413. Path: "model/mysql/datasource/shorthand2",
  414. Cmd: `goctl model mysql datasource -url $DSN -dir nocache -t "*" -c`,
  415. },
  416. {
  417. IsDir: true,
  418. Path: "model/mysql/datasource/assign",
  419. Cmd: `goctl model mysql datasource --url=$DSN --dir=nocache --table="*" -c`,
  420. },
  421. {
  422. IsDir: true,
  423. Path: "model/mysql/datasource/shorthand/assign",
  424. Cmd: `goctl model mysql datasource -url=$DSN -dir=nocache -table="*" -c`,
  425. },
  426. {
  427. IsDir: true,
  428. Path: "model/mysql/datasource/shorthand2/assign",
  429. Cmd: `goctl model mysql datasource -url=$DSN -dir=nocache -t="*" -c`,
  430. },
  431. {
  432. IsDir: true,
  433. Path: "rpc/new",
  434. Cmd: "goctl rpc new greet",
  435. },
  436. {
  437. IsDir: true,
  438. Path: "rpc/template",
  439. Cmd: "goctl rpc template --o greet.proto",
  440. },
  441. {
  442. IsDir: true,
  443. Path: "rpc/template/shorthand",
  444. Cmd: "goctl rpc template -o greet.proto",
  445. },
  446. {
  447. IsDir: true,
  448. Path: "rpc/template/assign",
  449. Cmd: "goctl rpc template --o=greet.proto",
  450. },
  451. {
  452. IsDir: true,
  453. Path: "rpc/template/shorthand/assign",
  454. Cmd: "goctl rpc template -o=greet.proto",
  455. },
  456. {
  457. IsDir: true,
  458. Path: "rpc/protoc",
  459. Cmd: "goctl rpc template --o greet.proto && goctl rpc protoc greet.proto --go_out . --go-grpc_out . --zrpc_out .",
  460. },
  461. {
  462. IsDir: true,
  463. Path: "rpc/protoc/assign",
  464. Cmd: "goctl rpc template --o=greet.proto && goctl rpc protoc greet.proto --go_out=. --go-grpc_out=. --zrpc_out=.",
  465. },
  466. }
  467. )