@@ -45,16 +45,18 @@ def test_manage_env_vars(yep_code_env):
45
45
46
46
47
47
def test_run_javascript_code (yep_code_run ):
48
+ random_comment = f"// random comment to avoid parallel executions conflict { random_hex ()} "
48
49
execution = yep_code_run .run (
49
- """async function main() {
50
- const message = `Hello, ${process.env.WORLD_ENV_VAR}!`
50
+ f"""async function main() {{
51
+ { random_comment }
52
+ const message = `Hello, ${{process.env.WORLD_ENV_VAR}}!`
51
53
console.log(message)
52
- return { message }
53
- }
54
+ return {{ message } }
55
+ }}
54
56
55
- module.exports = {
57
+ module.exports = {{
56
58
main,
57
- };""" ,
59
+ }} ;""" ,
58
60
{"removeOnDone" : True },
59
61
)
60
62
execution .wait_for_done ()
@@ -63,13 +65,15 @@ def test_run_javascript_code(yep_code_run):
63
65
64
66
65
67
def test_run_python_code (yep_code_run ):
68
+ random_comment = f"# random comment to avoid parallel executions conflict { random_hex ()} "
66
69
execution = yep_code_run .run (
67
- """import os
70
+ f """import os
68
71
69
72
def main():
70
- message = f"Hello, {os.getenv('WORLD_ENV_VAR')}!"
73
+ { random_comment }
74
+ message = f"Hello, {{os.getenv('WORLD_ENV_VAR')}}!"
71
75
print(message)
72
- return {"message": message}""" ,
76
+ return {{ "message": message} }""" ,
73
77
{"removeOnDone" : True },
74
78
)
75
79
execution .wait_for_done ()
@@ -79,14 +83,16 @@ def main():
79
83
80
84
def test_trigger_on_log (yep_code_run ):
81
85
logs = []
86
+ random_comment = f"// random comment to avoid parallel executions conflict { random_hex ()} "
82
87
execution = yep_code_run .run (
83
- """async function main() {
88
+ f"""async function main() {{
89
+ { random_comment }
84
90
console.log("Log message 1")
85
91
console.log("Log message 2")
86
- return { success: true }
87
- }
92
+ return {{ success: true } }
93
+ }}
88
94
89
- module.exports = { main };""" ,
95
+ module.exports = {{ main } };""" ,
90
96
{
91
97
"removeOnDone" : True ,
92
98
"onLog" : lambda log_entry : logs .append (log_entry .message ),
@@ -106,11 +112,11 @@ def on_finish(return_value):
106
112
finish_value = return_value
107
113
108
114
execution = yep_code_run .run (
109
- """async function main() {
110
- return { data: "test data" }
111
- }
115
+ f """async function main() { {
116
+ return {{ data: "test data" } }
117
+ }}
112
118
113
- module.exports = { main };""" ,
119
+ module.exports = {{ main } };""" ,
114
120
{"removeOnDone" : True , "onFinish" : on_finish },
115
121
)
116
122
@@ -120,17 +126,18 @@ def on_finish(return_value):
120
126
121
127
def test_trigger_on_error (yep_code_run ):
122
128
error_message = None
123
-
129
+ random_comment = f"// random comment to avoid parallel executions conflict { random_hex () } "
124
130
def on_error (error ):
125
131
nonlocal error_message
126
132
error_message = error ["message" ]
127
133
128
134
execution = yep_code_run .run (
129
- """async function main() {
135
+ f"""async function main() {{
136
+ { random_comment }
130
137
throw new Error("Test error");
131
- }
138
+ }}
132
139
133
- module.exports = { main };""" ,
140
+ module.exports = {{ main } };""" ,
134
141
{"removeOnDone" : True , "onError" : on_error },
135
142
)
136
143
@@ -141,16 +148,17 @@ def on_error(error):
141
148
def test_handle_all_events_python (yep_code_run ):
142
149
logs = []
143
150
finish_value = None
144
-
151
+ random_comment = f"# random comment to avoid parallel executions conflict { random_hex () } "
145
152
def on_finish (return_value ):
146
153
nonlocal finish_value
147
154
finish_value = return_value
148
155
149
156
execution = yep_code_run .run (
150
- """def main():
157
+ f"""def main():
158
+ { random_comment }
151
159
print("Log message 1")
152
160
print("Log message 2")
153
- return {"data": "python test"}""" ,
161
+ return {{ "data": "python test"} }""" ,
154
162
{
155
163
"language" : "python" ,
156
164
"removeOnDone" : True ,
0 commit comments