Skip to content

Commit

Permalink
fix: 修复用例执行返回体错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiaolulu committed Sep 27, 2024
1 parent bde2e17 commit 28fafbf
Show file tree
Hide file tree
Showing 19 changed files with 13,456 additions and 76 deletions.
50 changes: 27 additions & 23 deletions unit-backend/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions unit-backend/api/dao/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:Created by Null.
"""
import json
import sys
from typing import (
Any,
List
Expand Down Expand Up @@ -39,6 +40,9 @@
)


executor_service = ExecutorServiceClient()


class HttpDao:

@staticmethod
Expand Down Expand Up @@ -236,7 +240,6 @@ async def run_api_doc(cls, api: dict):
Raises:
Exception: If an error occurs during the API test run.
"""
executor_service = ExecutorServiceClient()
try:
api = HandelTestData(api)
api_data = api.get_api_template()
Expand Down Expand Up @@ -403,7 +406,7 @@ def parser_case_data(request: Any, pk=None):
raise Exception("解析测试用例失败 ❌")

@classmethod
def run_case_steps(cls, data: dict):
async def run_case_steps(cls, data: dict):
"""
Runs a test case based on the provided data and associated step data.
Expand All @@ -416,13 +419,12 @@ def run_case_steps(cls, data: dict):
Raises:
Exception: If an error occurs during the test case run.
"""

try:
runner = HandelTestData()
steps = data.get('step_data', [])
name = data.get('name', 'Demo')
case_data = runner.get_case_template(steps, name)
result = run_test(case_data)
result = await executor_service.run_case(case_data)
return result
except Exception as e:
logger.debug(
Expand Down
9 changes: 9 additions & 0 deletions unit-backend/api/services/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ async def run_api_doc(self, api_doc):
)
response = await stub.RunApiDoc(request)
return response

async def run_case(self, case_data):

async with ExecutorStub() as stub:
request = executor_pb2.CaseRequest(
**case_data
)
response = await stub.RunCase(request)
return response
10 changes: 8 additions & 2 deletions unit-backend/api/services/protos/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ message ApiDocRequest {
repeated ApiDocRequest children = 10;
}

message CaseRequest {
string name = 1;
repeated ApiDocRequest cases = 2;
}

message ValidateExtractor {
string expected = 1;
string methods = 2;
Expand Down Expand Up @@ -92,7 +97,7 @@ message ClassList{
string state = 8;
}

message ApiDocResponse{
message ExecutorResponse{
int32 all = 1;
int32 success = 2;
int32 error = 3;
Expand All @@ -107,5 +112,6 @@ message ApiDocResponse{
}

service ExecutorService{
rpc RunApiDoc(ApiDocRequest) returns (ApiDocResponse);
rpc RunApiDoc(ApiDocRequest) returns (ExecutorResponse);
rpc RunCase(CaseRequest) returns (ExecutorResponse);
}
Loading

0 comments on commit 28fafbf

Please sign in to comment.