Skip to content

Commit

Permalink
test generation code command
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Mar 2, 2024
1 parent 50ba35a commit 56d6359
Show file tree
Hide file tree
Showing 7 changed files with 375 additions and 46 deletions.
34 changes: 17 additions & 17 deletions test/auto-test/1_web_gin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ function stopService() {
function testRequest() {
echo "--------------------- 20s 后测试开始 ---------------------"
sleep 20
for i in {1..3}; do
echo -e "\n\n"
echo "${i} 获取详情 [GET] curl http://localhost:8080/api/v1/teacher/1"
curl http://localhost:8080/api/v1/teacher/1
echo -e "\n\n"
sleep 3

echo -e "\n\n"
echo "${i} 获取列表 [GET] curl http://localhost:8080/api/v1/teacher/list"
curl http://localhost:8080/api/v1/teacher/list
echo -e "\n\n"
sleep 3
echo -e "\n\n"
echo "$获取详情 [GET] curl http://localhost:8080/api/v1/${mysqlTable}/1"
curl http://localhost:8080/api/v1/${mysqlTable}/1
echo -e "\n\n"
sleep 3

echo -e "\n\n"
echo "获取列表1 [GET] curl http://localhost:8080/api/v1/${mysqlTable}/list"
curl http://localhost:8080/api/v1/${mysqlTable}/list
echo -e "\n\n"
sleep 3

echo -e "\n\n"
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}"'
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}"
echo -e "\n\n"
sleep 3

echo -e "\n\n"
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}"'
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}"
echo -e "\n\n"
sleep 3
done
echo ""
echo "--------------------- 测试结束!---------------------"
stopService
Expand Down
32 changes: 16 additions & 16 deletions test/auto-test/2_micro_grpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ function testRequest() {
echo "--------------------- 20s 后测试开始 ---------------------"
sleep 20
cd internal/service
for i in {1..3}; do
echo -e "\n\n"
echo "${i} 获取详情 go test -run Test_service_teacher_methods/GetByID id=1"
sed -i "s/Id: 0,/Id: 1,/g" teacher_client_test.go
go test -run Test_service_teacher_methods/GetByID
sed -i "s/Id: 1,/Id: 0,/g" teacher_client_test.go
echo -e "\n\n"
sleep 3

echo -e "\n\n"
echo "${i} 获取列表 go test -run Test_service_teacher_methods/ListByLastID"
sed -i "s/Limit: 0,/Limit: 3,/g" teacher_client_test.go
go test -run Test_service_teacher_methods/ListByLastID
sed -i "s/Limit: 3,/Limit: 0,/g" teacher_client_test.go
echo -e "\n\n"
sleep 3
done
echo -e "\n\n"
echo "获取详情 go test -run Test_service_${mysqlTable}_methods/GetByID id=1"
sed -i "s/Id: 0,/Id: 1,/g" ${mysqlTable}_client_test.go
go test -run Test_service_${mysqlTable}_methods/GetByID
sed -i "s/Id: 1,/Id: 0,/g" ${mysqlTable}_client_test.go
echo -e "\n\n"
sleep 3

echo -e "\n\n"
echo "获取列表 go test -run Test_service_${mysqlTable}_methods/ListByLastID"
sed -i "s/Limit: 0,/Limit: 3,/g" ${mysqlTable}_client_test.go
go test -run Test_service_${mysqlTable}_methods/ListByLastID
sed -i "s/Limit: 3,/Limit: 0,/g" ${mysqlTable}_client_test.go
echo -e "\n\n"
sleep 3

cd -
echo "--------------------- 测试结束!---------------------"
stopService
Expand Down
24 changes: 12 additions & 12 deletions test/auto-test/3_web_gin_pb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ function stopService() {
function testRequest() {
echo "--------------------- 20s 后测试开始 ---------------------"
sleep 20
for i in {1..3}; do
echo -e "\n\n"
echo ${i} 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"'
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"
echo -e "\n\n"
sleep 3

echo -e "\n\n"
echo 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"'
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"
echo -e "\n\n"
sleep 3
done
echo -e "\n\n"
echo 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"'
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"
echo -e "\n\n"
sleep 3

echo -e "\n\n"
echo 'curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"'
curl -X POST http://localhost:8080/api/v1/auth/register -H "Content-Type: application/json" -H "X-Request-Id: qaz12wx3ed4" -d "{\"email\":\"[email protected]\",\"password\":\"123456\"}"
echo -e "\n\n"
sleep 3

echo "--------------------- 测试结束!---------------------"
stopService
}
Expand Down
2 changes: 1 addition & 1 deletion test/auto-test/5_grpc_gateway_pb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ else
checkResult $?

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

echo "复制proto文件到rpc网关目录"
Expand Down
16 changes: 16 additions & 0 deletions test/auto-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,19 @@ After testing, remove the code generated during the testing process.
```bash
bash clean.sh
```

<br>

## Generate Command Test

A total of 13 service codes are generated, including web, grpc, grpc gateway services

```bash
bash generate_test.sh
```

After testing, remove the code generated code.

```bash
bash clean_generate.sh
```
3 changes: 3 additions & 0 deletions test/auto-test/clean_generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

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
Loading

0 comments on commit 56d6359

Please sign in to comment.