[SEMANTIC-65] [Bug] Environment variables in tests doesn't match test.env.example file
rijnhardtkotze opened this issue · 2 comments
rijnhardtkotze commented
Is this a new bug in dbt_metrics?
- I believe this is a new bug in dbt_metrics
- I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
Currently, the environment variables required to run the tests locally are not named correctly in the test.env.example
file. Additionally, a required dbt_target
field is not provided in the example file.
Expected Behavior
The naming should be:
POSTGRES_TEST_PASS -> POSTGRES_TEST_PASSWORD
POSTGRES_TEST_DBNAME -> POSTGRES_TEST_DB
Additionally, a new dbt_target
field should be added.
Steps To Reproduce
- Clone the repo locally
- Delete the
test.env
file locally, if it exists - Rename the
test.env.example
file totest.env
- Try run the test suite.
Relevant log output
______________ ERROR at setup of TestDoubleQuoteRefMetrics.test_build_completion ________________
@pytest.fixture(scope="class")
def dbt_profile_target():
> if os.environ['dbt_target'] == 'postgres':
tests/conftest.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = environ({'TERM_SESSION_ID': 'w0t0p0:0123D657-2792-4106-9A52-4778E89EFDAA', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.la...ric_options/metric_reference/test_double_quote_ref_name.py::TestDoubleQuoteRefMetrics::test_build_completion (setup)'}), key = 'dbt_target'
def __getitem__(self, key):
try:
value = self._data[self.encodekey(key)]
except KeyError:
# raise KeyError with the original key value
> raise KeyError(key) from None
E KeyError: 'dbt_target'
../../../.pyenv/versions/3.10.4/lib/python3.10/os.py:679: KeyError
After you provide the dbt_target
key, you get the following errors:
______________ ERROR at setup of TestDefaultValueNullMetric.test_build_completion ______________
@pytest.fixture(scope="class")
def dbt_profile_target():
if os.environ['dbt_target'] == 'postgres':
return {
'type': 'postgres',
'threads': 1,
'host': os.environ['POSTGRES_TEST_HOST'],
'user': os.environ['POSTGRES_TEST_USER'],
> 'password': os.environ['POSTGRES_TEST_PASSWORD'],
'port': int(os.environ['POSTGRES_TEST_PORT']),
'database': os.environ['POSTGRES_TEST_DB'],
}
tests/conftest.py:24:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = environ({'TERM_SESSION_ID': 'w0t0p0:0123D657-2792-4106-9A52-4778E89EFDAA', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.la...eat_null_values_as_zero/test_treat_null_values_as_zero.py::TestDefaultValueNullMetric::test_build_completion (setup)'}), key = 'POSTGRES_TEST_PASSWORD'
def __getitem__(self, key):
try:
value = self._data[self.encodekey(key)]
except KeyError:
# raise KeyError with the original key value
> raise KeyError(key) from None
E KeyError: 'POSTGRES_TEST_PASSWORD'
Environment
- dbt-adapter & version: dbt-postgres v1.3.0
- dbt_metrics version: main branch
Which database adapter are you using with dbt?
postgres
Additional Context
I am happy to write a fix for this. Seems like it should just require an update to:
test.env.example
file
rijnhardtkotze commented
PR is open at #179
callum-mcdata commented
@rijnhardtkotze good find! Added a single comment to reinforce that we recommend using Postgres for local development but beyond that it looks good to me. Lets move over to the PR to get it over the line.