-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowed spaces in variable resolving
- Loading branch information
1 parent
6a84972
commit 8dfb222
Showing
3 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
soda-core/tests/soda_core/tests/components/test_variable_resolver.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from textwrap import dedent | ||
|
||
from soda_core.common.yaml import VariableResolver | ||
|
||
|
||
def test_variable(): | ||
src=dedent(""" | ||
host: ${HOST} | ||
""").strip() | ||
|
||
result = VariableResolver.resolve(source_text_with_variables=src, variables={"HOST": "test.soda.io"}) | ||
assert "host: test.soda.io" == result | ||
|
||
|
||
def test_variable_with_spaces(): | ||
src=dedent(""" | ||
host: ${ HOST } | ||
""").strip() | ||
|
||
result = VariableResolver.resolve(source_text_with_variables=src, variables={"HOST": "test.soda.io"}) | ||
assert "host: test.soda.io" == result | ||
|
||
|
||
def test_variable_env_var(env_vars: dict): | ||
src=dedent(""" | ||
host: ${HOST} | ||
""").strip() | ||
|
||
env_vars["HOST"] = "test.soda.io" | ||
|
||
result = VariableResolver.resolve(source_text_with_variables=src) | ||
assert "host: test.soda.io" == result | ||
|
||
|
||
def test_variable_not_found(): | ||
src=dedent(""" | ||
host: ${HOST} | ||
""").strip() | ||
|
||
result = VariableResolver.resolve(source_text_with_variables=src) | ||
assert "host: ${HOST}" == result |