feat: add 15 auto-test functions + destroy-test + versioning rules
Batch 1: ok, echo, error, cpu, slow Batch 2: jsonout, recurse, bigdata, math, timestamp Batch 3: multiline, encoding, nested, memory, chain Tests: create, update (code_hash), idempotency, destroy, re-create All 15 functions verified via curl with JWT auth
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
def main():
|
||||
lines = []
|
||||
for i in range(500):
|
||||
lines.append(f"line-{i}: {'x' * 80}")
|
||||
return "\n".join(lines)
|
||||
@@ -0,0 +1,9 @@
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
def main():
|
||||
data = {"step": 1, "value": "start"}
|
||||
for i in range(2, 6):
|
||||
h = hashlib.sha256(json.dumps(data).encode()).hexdigest()[:8]
|
||||
data = {"step": i, "prev_hash": h, "value": f"chain-{i}"}
|
||||
return json.dumps(data)
|
||||
@@ -0,0 +1,5 @@
|
||||
def main():
|
||||
s = 0
|
||||
for i in range(1, 100000):
|
||||
s += (i * i) % 97
|
||||
return f"cpu-load:{s}"
|
||||
@@ -0,0 +1,5 @@
|
||||
def main():
|
||||
s = 0
|
||||
for i in range(1, 100000):
|
||||
s += (i * i) % 97
|
||||
return f"cpu-load:{s}"
|
||||
@@ -0,0 +1,4 @@
|
||||
def main():
|
||||
import os
|
||||
msg = os.environ.get("FISSION_INPUT", "echo-default")
|
||||
return f"echo:{msg}"
|
||||
@@ -0,0 +1,5 @@
|
||||
import os
|
||||
|
||||
def main():
|
||||
msg = os.environ.get("FISSION_INPUT", "echo-default")
|
||||
return f"echo:{msg}"
|
||||
@@ -0,0 +1,5 @@
|
||||
def main():
|
||||
emoji = "\U0001f680\U0001f525\u2764\ufe0f"
|
||||
cyrillic = "\u041f\u0440\u0438\u0432\u0435\u0442 \u043c\u0438\u0440!"
|
||||
chinese = "\u4f60\u597d\u4e16\u754c"
|
||||
return f"emoji:{emoji} cyr:{cyrillic} zh:{chinese}"
|
||||
@@ -0,0 +1,2 @@
|
||||
def main():
|
||||
raise Exception("auto-error-test")
|
||||
@@ -0,0 +1,2 @@
|
||||
def main():
|
||||
raise Exception("auto-error-test")
|
||||
@@ -0,0 +1,9 @@
|
||||
import json
|
||||
|
||||
def main():
|
||||
data = {
|
||||
"status": "ok",
|
||||
"items": [{"id": i, "value": i * i} for i in range(10)],
|
||||
"count": 10
|
||||
}
|
||||
return json.dumps(data)
|
||||
@@ -0,0 +1,12 @@
|
||||
import math
|
||||
|
||||
def main():
|
||||
results = {
|
||||
"pi": round(math.pi, 10),
|
||||
"e": round(math.e, 10),
|
||||
"sqrt2": round(math.sqrt(2), 10),
|
||||
"factorial20": math.factorial(20),
|
||||
"log1000": round(math.log(1000), 10),
|
||||
}
|
||||
parts = [f"{k}={v}" for k, v in results.items()]
|
||||
return "; ".join(parts)
|
||||
@@ -0,0 +1,6 @@
|
||||
import sys
|
||||
|
||||
def main():
|
||||
big_list = list(range(500000))
|
||||
size_mb = sys.getsizeof(big_list) / (1024 * 1024)
|
||||
return f"memory-alloc:{size_mb:.2f}MB len={len(big_list)}"
|
||||
@@ -0,0 +1,5 @@
|
||||
def main():
|
||||
return """line1
|
||||
line2
|
||||
line3
|
||||
Конец (кириллица)"""
|
||||
@@ -0,0 +1,9 @@
|
||||
def main():
|
||||
try:
|
||||
a = 1 / 0
|
||||
except ZeroDivisionError:
|
||||
try:
|
||||
raise ValueError("nested after div-by-zero")
|
||||
except ValueError as e:
|
||||
return f"caught-nested:{e}"
|
||||
return "unreachable"
|
||||
@@ -0,0 +1,2 @@
|
||||
def main():
|
||||
return "ok-auto-func"
|
||||
@@ -0,0 +1,2 @@
|
||||
def main():
|
||||
return "ok-auto-func-UPDATED-v2"
|
||||
@@ -0,0 +1,8 @@
|
||||
def fib(n):
|
||||
if n <= 1:
|
||||
return n
|
||||
return fib(n - 1) + fib(n - 2)
|
||||
|
||||
def main():
|
||||
result = fib(30)
|
||||
return f"fib(30)={result}"
|
||||
@@ -0,0 +1,4 @@
|
||||
import time
|
||||
def main():
|
||||
time.sleep(2)
|
||||
return "slow-done"
|
||||
@@ -0,0 +1,5 @@
|
||||
import time
|
||||
|
||||
def main():
|
||||
time.sleep(2)
|
||||
return "slow-done"
|
||||
@@ -0,0 +1,5 @@
|
||||
import datetime
|
||||
|
||||
def main():
|
||||
now = datetime.datetime.utcnow().isoformat()
|
||||
return f"timestamp:{now}Z"
|
||||
Reference in New Issue
Block a user