@@ -45,16 +45,18 @@ def test_manage_env_vars(yep_code_env):
4545
4646
4747def test_run_javascript_code (yep_code_run ):
48+ random_comment = f"// random comment to avoid parallel executions conflict { random_hex ()} "
4849 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}}!`
5153 console.log(message)
52- return { message }
53- }
54+ return {{ message } }
55+ }}
5456
55- module.exports = {
57+ module.exports = {{
5658 main,
57- };""" ,
59+ }} ;""" ,
5860 {"removeOnDone" : True },
5961 )
6062 execution .wait_for_done ()
@@ -63,13 +65,15 @@ def test_run_javascript_code(yep_code_run):
6365
6466
6567def test_run_python_code (yep_code_run ):
68+ random_comment = f"# random comment to avoid parallel executions conflict { random_hex ()} "
6669 execution = yep_code_run .run (
67- """import os
70+ f """import os
6871
6972def main():
70- message = f"Hello, {os.getenv('WORLD_ENV_VAR')}!"
73+ { random_comment }
74+ message = f"Hello, {{os.getenv('WORLD_ENV_VAR')}}!"
7175 print(message)
72- return {"message": message}""" ,
76+ return {{ "message": message} }""" ,
7377 {"removeOnDone" : True },
7478 )
7579 execution .wait_for_done ()
@@ -79,14 +83,16 @@ def main():
7983
8084def test_trigger_on_log (yep_code_run ):
8185 logs = []
86+ random_comment = f"// random comment to avoid parallel executions conflict { random_hex ()} "
8287 execution = yep_code_run .run (
83- """async function main() {
88+ f"""async function main() {{
89+ { random_comment }
8490 console.log("Log message 1")
8591 console.log("Log message 2")
86- return { success: true }
87- }
92+ return {{ success: true } }
93+ }}
8894
89- module.exports = { main };""" ,
95+ module.exports = {{ main } };""" ,
9096 {
9197 "removeOnDone" : True ,
9298 "onLog" : lambda log_entry : logs .append (log_entry .message ),
@@ -106,11 +112,11 @@ def on_finish(return_value):
106112 finish_value = return_value
107113
108114 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+ }}
112118
113- module.exports = { main };""" ,
119+ module.exports = {{ main } };""" ,
114120 {"removeOnDone" : True , "onFinish" : on_finish },
115121 )
116122
@@ -120,17 +126,18 @@ def on_finish(return_value):
120126
121127def test_trigger_on_error (yep_code_run ):
122128 error_message = None
123-
129+ random_comment = f"// random comment to avoid parallel executions conflict { random_hex () } "
124130 def on_error (error ):
125131 nonlocal error_message
126132 error_message = error ["message" ]
127133
128134 execution = yep_code_run .run (
129- """async function main() {
135+ f"""async function main() {{
136+ { random_comment }
130137 throw new Error("Test error");
131- }
138+ }}
132139
133- module.exports = { main };""" ,
140+ module.exports = {{ main } };""" ,
134141 {"removeOnDone" : True , "onError" : on_error },
135142 )
136143
@@ -141,16 +148,17 @@ def on_error(error):
141148def test_handle_all_events_python (yep_code_run ):
142149 logs = []
143150 finish_value = None
144-
151+ random_comment = f"# random comment to avoid parallel executions conflict { random_hex () } "
145152 def on_finish (return_value ):
146153 nonlocal finish_value
147154 finish_value = return_value
148155
149156 execution = yep_code_run .run (
150- """def main():
157+ f"""def main():
158+ { random_comment }
151159 print("Log message 1")
152160 print("Log message 2")
153- return {"data": "python test"}""" ,
161+ return {{ "data": "python test"} }""" ,
154162 {
155163 "language" : "python" ,
156164 "removeOnDone" : True ,
0 commit comments