Files
turso/antithesis-tests/stress-composer/helper_utils.py
Pekka Enberg 7f7ad90244 antithesis-tests: Rename "utils.py" to "helper_utils.py"
Antithesis is now supposed to detect that this is not a runnable driver
and not complain about it.
2025-09-24 14:28:35 +03:00

23 lines
723 B
Python
Executable File

import string
from antithesis.random import get_random, random_choice
def generate_random_identifier(type: str, num: int):
return "".join(type, "_", get_random() % num)
def generate_random_value(type_str):
if type_str == "INTEGER":
return str(get_random() % 100)
elif type_str == "REAL":
return "{:.2f}".format(get_random() % 100 / 100.0)
elif type_str == "TEXT":
return f"'{''.join(random_choice(string.ascii_lowercase) for _ in range(5))}'"
elif type_str == "BLOB":
return f"x'{''.join(random_choice(string.ascii_lowercase) for _ in range(5)).encode().hex()}'"
elif type_str == "NUMERIC":
return str(get_random() % 100)
else:
return "NULL"