Skip to content

Commit

Permalink
fix problem when missing custom variables (#23)
Browse files Browse the repository at this point in the history
* fix: str_to_bool not working as expectedd

* test: test if other valid yaml boolean types work

* fix: error when no custom variables are specified

---------

Co-authored-by: nm1 <[email protected]>
  • Loading branch information
NikodemMarek and nm1 authored Jun 7, 2024
1 parent ca1b69a commit 77b257b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/common/resolver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@


class TestStringResolver(unittest.TestCase):
def test_resolve_no_custom_vars(self):
# given:
init_str_resolver("1.0", "token123")
init_str_resolver_custom_variables(None)

# when:
resolved_string = resolve("Testing {VERSION}")

# then:
self.assertEqual("Testing 1.0", resolved_string)

def test_resolve_predefined(self):
# given:
Expand Down
3 changes: 2 additions & 1 deletion valhalla/common/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def init_str_resolver(version: str, token: str):

def init_str_resolver_custom_variables(variables: dict):
global CUSTOM_VARIABLES_DICT
CUSTOM_VARIABLES_DICT.update(variables)

CUSTOM_VARIABLES_DICT.update({} if variables is None else variables)

for key, value in CUSTOM_VARIABLES_DICT.items():
info(f"Custom variable: {key} set to: {value}")
Expand Down

0 comments on commit 77b257b

Please sign in to comment.