Skip to content

Commit 56d6359

Browse files
committed
test generation code command
1 parent 50ba35a commit 56d6359

File tree

7 files changed

+375
-46
lines changed

7 files changed

+375
-46
lines changed

test/auto-test/1_web_gin.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ function stopService() {
2323
function testRequest() {
2424
echo "--------------------- 20s 后测试开始 ---------------------"
2525
sleep 20
26-
for i in {1..3}; do
27-
echo -e "\n\n"
28-
echo "${i} 获取详情 [GET] curl http://localhost:8080/api/v1/teacher/1"
29-
curl http://localhost:8080/api/v1/teacher/1
30-
echo -e "\n\n"
31-
sleep 3
3226

33-
echo -e "\n\n"
34-
echo "${i} 获取列表 [GET] curl http://localhost:8080/api/v1/teacher/list"
35-
curl http://localhost:8080/api/v1/teacher/list
36-
echo -e "\n\n"
37-
sleep 3
27+
echo -e "\n\n"
28+
echo "$获取详情 [GET] curl http://localhost:8080/api/v1/${mysqlTable}/1"
29+
curl http://localhost:8080/api/v1/${mysqlTable}/1
30+
echo -e "\n\n"
31+
sleep 3
32+
33+
echo -e "\n\n"
34+
echo "获取列表1 [GET] curl http://localhost:8080/api/v1/${mysqlTable}/list"
35+
curl http://localhost:8080/api/v1/${mysqlTable}/list
36+
echo -e "\n\n"
37+
sleep 3
38+
39+
echo -e "\n\n"
40+
echo '获取列表2 [POST] curl -X POST http://localhost:8080/api/v1/${mysqlTable}/list -H "X-Request-Id: qaz12wx3ed4" -H "Content-Type: application/json" -d "{\"columns\":[{\"exp\":\">\",\"name\":\"id\",\"value\":1}],\"page\":0,\"size\":10}"'
41+
curl -X POST http://localhost:8080/api/v1/${mysqlTable}/list -H "X-Request-Id: qaz12wx3ed4" -H "Content-Type: application/json" -d "{\"columns\":[{\"exp\":\">\",\"name\":\"id\",\"value\":1}],\"page\":0,\"size\":10}"
42+
echo -e "\n\n"
43+
sleep 3
3844

39-
echo -e "\n\n"
40-
echo ${i}' 获取列表 [POST] curl -X POST http://localhost:8080/api/v1/teacher/list -H "X-Request-Id: qaz12wx3ed4" -H "Content-Type: application/json" -d "{\"columns\":[{\"exp\":\">\",\"name\":\"id\",\"value\":1}],\"page\":0,\"size\":10}"'
41-
curl -X POST http://localhost:8080/api/v1/teacher/list -H "X-Request-Id: qaz12wx3ed4" -H "Content-Type: application/json" -d "{\"columns\":[{\"exp\":\">\",\"name\":\"id\",\"value\":1}],\"page\":0,\"size\":10}"
42-
echo -e "\n\n"
43-
sleep 3
44-
done
4545
echo ""
4646
echo "--------------------- 测试结束!---------------------"
4747
stopService

test/auto-test/2_micro_grpc.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ function testRequest() {
2424
echo "--------------------- 20s 后测试开始 ---------------------"
2525
sleep 20
2626
cd internal/service
27-
for i in {1..3}; do
28-
echo -e "\n\n"
29-
echo "${i} 获取详情 go test -run Test_service_teacher_methods/GetByID id=1"
30-
sed -i "s/Id: 0,/Id: 1,/g" teacher_client_test.go
31-
go test -run Test_service_teacher_methods/GetByID
32-
sed -i "s/Id: 1,/Id: 0,/g" teacher_client_test.go
33-
echo -e "\n\n"
34-
sleep 3
3527

36-
echo -e "\n\n"
37-
echo "${i} 获取列表 go test -run Test_service_teacher_methods/ListByLastID"
38-
sed -i "s/Limit: 0,/Limit: 3,/g" teacher_client_test.go
39-
go test -run Test_service_teacher_methods/ListByLastID
40-
sed -i "s/Limit: 3,/Limit: 0,/g" teacher_client_test.go
41-
echo -e "\n\n"
42-
sleep 3
43-
done
28+
echo -e "\n\n"
29+
echo "获取详情 go test -run Test_service_${mysqlTable}_methods/GetByID id=1"
30+
sed -i "s/Id: 0,/Id: 1,/g" ${mysqlTable}_client_test.go
31+
go test -run Test_service_${mysqlTable}_methods/GetByID
32+
sed -i "s/Id: 1,/Id: 0,/g" ${mysqlTable}_client_test.go
33+
echo -e "\n\n"
34+
sleep 3
35+
36+
echo -e "\n\n"
37+
echo "获取列表 go test -run Test_service_${mysqlTable}_methods/ListByLastID"
38+
sed -i "s/Limit: 0,/Limit: 3,/g" ${mysqlTable}_client_test.go
39+
go test -run Test_service_${mysqlTable}_methods/ListByLastID
40+
sed -i "s/Limit: 3,/Limit: 0,/g" ${mysqlTable}_client_test.go
41+
echo -e "\n\n"
42+
sleep 3
43+
4444
cd -
4545
echo "--------------------- 测试结束!---------------------"
4646
stopService

test/auto-test/3_web_gin_pb.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ function stopService() {
2020
function testRequest() {
2121
echo "--------------------- 20s 后测试开始 ---------------------"
2222
sleep 20
23-
for i in {1..3}; do
24-
echo -e "\n\n"
25-
echo ${i} 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"'
26-
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"
27-
echo -e "\n\n"
28-
sleep 3
2923

30-
echo -e "\n\n"
31-
echo 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"'
32-
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"
33-
echo -e "\n\n"
34-
sleep 3
35-
done
24+
echo -e "\n\n"
25+
echo 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"'
26+
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"
27+
echo -e "\n\n"
28+
sleep 3
29+
30+
echo -e "\n\n"
31+
echo 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"'
32+
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"foo@bar.com\",\"password\":\"123456\"}"
33+
echo -e "\n\n"
34+
sleep 3
35+
3636
echo "--------------------- 测试结束!---------------------"
3737
stopService
3838
}

test/auto-test/5_grpc_gateway_pb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ else
9494
checkResult $?
9595

9696
echo "修改配置文件的grpcClient字段"
97-
sed -i "s/your-rpc-server-name/user/g" ./${rpcGwDir}/configs/user_gw.yml
97+
sed -i "s/your_grpc_service_name/user/g" ./${rpcGwDir}/configs/user_gw.yml
9898
checkResult $?
9999

100100
echo "复制proto文件到rpc网关目录"

test/auto-test/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,19 @@ After testing, remove the code generated during the testing process.
3232
```bash
3333
bash clean.sh
3434
```
35+
36+
<br>
37+
38+
## Generate Command Test
39+
40+
A total of 13 service codes are generated, including web, grpc, grpc gateway services
41+
42+
```bash
43+
bash generate_test.sh
44+
```
45+
46+
After testing, remove the code generated code.
47+
48+
```bash
49+
bash clean_generate.sh
50+
```

test/auto-test/clean_generate.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
rm -rf http-mysql http-postgresql http-sqlite http-mongodb grpc-mysql grpc-postgresql grpc-sqlite grpc-mongodb http-pb-mysql http-pb-mongodb grpc-pb-mysql grpc-pb-mongodb grpc-gw-pb

0 commit comments

Comments
 (0)