fix: Apply black formatting to resolve CI formatting issues
This commit is contained in:
@@ -86,7 +86,9 @@ class GoGenerator:
|
||||
|
||||
return generated_files
|
||||
|
||||
def _group_endpoints_by_path(self, endpoints: List[Dict[str, Any]]) -> Dict[str, List[Dict[str, Any]]]:
|
||||
def _group_endpoints_by_path(
|
||||
self, endpoints: List[Dict[str, Any]]
|
||||
) -> Dict[str, List[Dict[str, Any]]]:
|
||||
"""Group endpoints by their path.
|
||||
|
||||
Args:
|
||||
@@ -133,7 +135,7 @@ class GoGenerator:
|
||||
test_name = self._generate_test_name(endpoint)
|
||||
params = self._generate_params(endpoint)
|
||||
|
||||
test_code = f'''
|
||||
test_code = f"""
|
||||
func Test{test_name}(t *testing.T) {{
|
||||
client := &http.Client{{Timeout: 10 * time.Second}}
|
||||
url := baseURL + "{endpoint['path']}"
|
||||
@@ -162,7 +164,7 @@ func Test{test_name}(t *testing.T) {{
|
||||
t.Errorf("Expected status code in [200, 201, 204], got %d", resp.StatusCode)
|
||||
}}
|
||||
}}
|
||||
'''
|
||||
"""
|
||||
return test_code
|
||||
|
||||
def _generate_test_name(self, endpoint: Dict[str, Any]) -> str:
|
||||
@@ -200,7 +202,15 @@ func Test{test_name}(t *testing.T) {{
|
||||
|
||||
if param["in"] == "path":
|
||||
params.append(f'{param_name} := "test_{param_name}"')
|
||||
params.append('url = strings.Replace(url, "' + '{' + param_name + '}' + '", ' + param_name + ', 1)')
|
||||
params.append(
|
||||
'url = strings.Replace(url, "'
|
||||
+ "{"
|
||||
+ param_name
|
||||
+ "}"
|
||||
+ '", '
|
||||
+ param_name
|
||||
+ ", 1)"
|
||||
)
|
||||
|
||||
elif param["in"] == "query":
|
||||
params.append(f'q := url.Values{{{param_name}: []string{{"test"}}}}')
|
||||
@@ -222,6 +232,14 @@ func Test{test_name}(t *testing.T) {{
|
||||
parts = []
|
||||
|
||||
for param in path_params:
|
||||
parts.append('strings.Replace(url, "' + '{' + param['name'] + '}' + '", "test_' + param['name'] + '", 1)')
|
||||
parts.append(
|
||||
'strings.Replace(url, "'
|
||||
+ "{"
|
||||
+ param["name"]
|
||||
+ "}"
|
||||
+ '", "test_'
|
||||
+ param["name"]
|
||||
+ '", 1)'
|
||||
)
|
||||
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user