Commit 251ec8e7 authored by Wade's avatar Wade

add test

parent e3ddfa73
......@@ -6,9 +6,6 @@ class ChatUser(HttpUser):
# Wait between 1 and 5 seconds between requests
wait_time = between(1, 5)
# Define the host (can be overridden in Locust UI or environment)
host = "http://54.92.111.204:8000"
@task
def post_chat(self):
# Define possible values for dynamic fields
......@@ -53,14 +50,12 @@ class ChatUser(HttpUser):
catch_response=True
) as response:
try:
# Parse response JSON
resp_json = response.json()
# Validate response
if resp_json.get("code") == 200 and resp_json.get("data"):
# Validate response based on HTTP status code
if response.status_code == 200:
response.success()
else:
response.failure(f"Unexpected code: {resp_json.get('code', 'N/A')} - {resp_json.get('msg', 'No message')}")
response.failure(f"Unexpected status code: {response.status_code} - {response.text}")
except ValueError:
response.failure(f"Invalid JSON response: {response.text}")
response.failure(f"Invalid response: {response.text}")
except Exception as e:
response.failure(f"Error: {str(e)}")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment