Skip to content

Commit 85c0715

Browse files
committed
CH-234 tests fix
1 parent 7757798 commit 85c0715

1 file changed

Lines changed: 42 additions & 31 deletions

File tree

tools/deployment-cli-tools/tests/test_codefresh.py

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -331,24 +331,16 @@ def test_create_codefresh_configuration_nobuild():
331331
assert "publish_myapp-mytask" in l1_steps["publish"]["steps"]
332332

333333

334-
<<<<<<< HEAD
335334
def test_codefresh_db_connect_string_secret():
336335
"""When an app has database.connect_string set to '', a custom_values entry must be added to the deployment step."""
337-
=======
338-
def test_codefresh_secret_with_quotes():
339-
>>>>>>> cb52695d5df61aa6f766cbebca386ee45ce95267
340336
values = create_helm_chart(
341337
[CLOUDHARNESS_ROOT, RESOURCES],
342338
output_path=OUT,
343339
include=['myapp'],
344340
exclude=['events'],
345341
domain="my.local",
346342
namespace='test',
347-
<<<<<<< HEAD
348343
env='connectstring',
349-
=======
350-
env='dev',
351-
>>>>>>> cb52695d5df61aa6f766cbebca386ee45ce95267
352344
local=False,
353345
tag=1,
354346
registry='reg'
@@ -359,10 +351,39 @@ def test_codefresh_secret_with_quotes():
359351
helm_values=values,
360352
merge_build_path=BUILD_MERGE_DIR
361353
)
362-
<<<<<<< HEAD
363354
build_included = [app['harness']['name']
364355
for app in values['apps'].values() if 'harness' in app]
365-
=======
356+
cf = create_codefresh_deployment_scripts(root_paths, include=build_included,
357+
envs=['dev'],
358+
base_image_name=values['name'],
359+
helm_values=values, save=False)
360+
custom_values = cf['steps']['deployment']['arguments']['custom_values']
361+
expected = "apps_myapp_harness_database_connect__string=\"${{MYAPP_DB_CONNECT_STRING}}\""
362+
assert expected in custom_values, \
363+
f"Expected custom_value entry for connect_string not found. Got: {custom_values}"
364+
finally:
365+
shutil.rmtree(BUILD_MERGE_DIR, ignore_errors=True)
366+
367+
368+
def test_codefresh_secret_with_quotes():
369+
values = create_helm_chart(
370+
[CLOUDHARNESS_ROOT, RESOURCES],
371+
output_path=OUT,
372+
include=['myapp'],
373+
exclude=['events'],
374+
domain="my.local",
375+
namespace='test',
376+
env='dev',
377+
local=False,
378+
tag=1,
379+
registry='reg'
380+
)
381+
try:
382+
root_paths = preprocess_build_overrides(
383+
root_paths=[CLOUDHARNESS_ROOT, RESOURCES],
384+
helm_values=values,
385+
merge_build_path=BUILD_MERGE_DIR
386+
)
366387

367388
build_included = [app['harness']['name']
368389
for app in values['apps'].values() if 'harness' in app]
@@ -371,16 +392,22 @@ def test_codefresh_secret_with_quotes():
371392
"settings_secret": "SECRET_KEY='replace-with-strong-shared-secret'"
372393
}
373394

374-
>>>>>>> cb52695d5df61aa6f766cbebca386ee45ce95267
375395
cf = create_codefresh_deployment_scripts(root_paths, include=build_included,
376396
envs=['dev'],
377397
base_image_name=values['name'],
378398
helm_values=values, save=False)
379-
<<<<<<< HEAD
399+
380400
custom_values = cf['steps']['deployment']['arguments']['custom_values']
381-
expected = "apps_myapp_harness_database_connect__string=${{MYAPP_DB_CONNECT_STRING}}"
382-
assert expected in custom_values, \
383-
f"Expected custom_value entry for connect_string not found. Got: {custom_values}"
401+
entry = next(
402+
value for value in custom_values
403+
if value.startswith("apps_myapp_harness_secrets_settings__secret=")
404+
)
405+
assert entry == 'apps_myapp_harness_secrets_settings__secret="${{SETTINGS__SECRET}}"'
406+
rendered = entry.replace(
407+
"${{SETTINGS__SECRET}}",
408+
values.apps["myapp"].harness.secrets["settings_secret"]
409+
)
410+
assert rendered == 'apps_myapp_harness_secrets_settings__secret="SECRET_KEY=\'replace-with-strong-shared-secret\'"'
384411
finally:
385412
shutil.rmtree(BUILD_MERGE_DIR, ignore_errors=True)
386413

@@ -541,22 +568,6 @@ def test_steps_ordered_by_stage_in_generated_config():
541568
finally:
542569
import shutil
543570
shutil.rmtree(BUILD_MERGE_DIR, ignore_errors=True)
544-
=======
545-
546-
custom_values = cf['steps']['deployment']['arguments']['custom_values']
547-
entry = next(
548-
value for value in custom_values
549-
if value.startswith("apps_myapp_harness_secrets_settings__secret=")
550-
)
551-
assert entry == 'apps_myapp_harness_secrets_settings__secret="${{SETTINGS__SECRET}}"'
552-
rendered = entry.replace(
553-
"${{SETTINGS__SECRET}}",
554-
values.apps["myapp"].harness.secrets["settings_secret"]
555-
)
556-
assert rendered == 'apps_myapp_harness_secrets_settings__secret="SECRET_KEY=\'replace-with-strong-shared-secret\'"'
557-
finally:
558-
shutil.rmtree(BUILD_MERGE_DIR)
559-
>>>>>>> cb52695d5df61aa6f766cbebca386ee45ce95267
560571

561572

562573
def test_app_depends_on_app():

0 commit comments

Comments
 (0)