-
Notifications
You must be signed in to change notification settings - Fork 1
/
e2e.py
63 lines (54 loc) · 1.58 KB
/
e2e.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import subprocess
import sys
import requests
proc = subprocess.Popen(
["go", "run", "."], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
addr = "http://localhost:8000"
if len(sys.argv) > 1:
addr = sys.argv[1]
try:
# set/get
s = requests.post(f"{addr}/set?key=a", data="b")
assert s.status_code == 200
print(s.status_code, s.text)
g = requests.get(f"{addr}/get?key=a")
print(g.status_code, g.text)
assert g.status_code == 200
assert g.text == "b"
# get missing
g = requests.get(f"{addr}/get?key=z")
print(g.status_code, g.text)
assert g.status_code == 404
# set without key
g = requests.get(f"{addr}/set")
print(g.status_code, g.text)
assert g.status_code == 400
# set with empty key
g = requests.get(f"{addr}/set?key=")
print(g.status_code, g.text)
assert g.status_code == 400
# set/get empty value
s = requests.post(f"{addr}/set?key=c")
print(s.status_code, g.text)
assert s.status_code == 200
g = requests.get(f"{addr}/get?key=c")
print(g.status_code, g.text)
assert g.status_code == 200
assert g.text == ""
# set/del/get
s = requests.post(f"{addr}/set?key=x", data="y")
print(s.status_code, g.text)
assert s.status_code == 200
d = requests.delete(f"{addr}/delete?key=c")
print(d.status_code, d.text)
assert d.status_code == 200
g = requests.get(f"{addr}/get?key=c")
print(g.status_code, g.text)
assert g.status_code == 404
print("tests pass 🚀")
except Exception as e:
print("tests fail 🛑")
raise
finally:
proc.terminate()