Skip to content

Commit

Permalink
Implement database config in project dir (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook authored and fantix committed Jun 18, 2023
1 parent 0f30b26 commit bee7327
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions edgedb/con_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,12 @@ def _parse_connect_dsn_and_args(
f'project defined cloud profile ("{cloud_profile}")'
),
)

opt_database_file = os.path.join(stash_dir, 'database')
if os.path.exists(opt_database_file):
with open(opt_database_file, 'rt') as f:
database = f.read().strip()
resolved_config.set_database(database, "project")
else:
raise errors.ClientConnectionError(
f'Found `edgedb.toml` but the project is not initialized. '
Expand Down
2 changes: 1 addition & 1 deletion tests/shared-client-testcases
4 changes: 4 additions & 0 deletions tests/test_con_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@


class TestConUtils(unittest.TestCase):
maxDiff = 1000

error_mapping = {
'credentials_file_not_found': (
Expand Down Expand Up @@ -184,6 +185,9 @@ def run_testcase(self, testcase):
if 'cloud-profile' in v:
profile = os.path.join(dir, 'cloud-profile')
files[profile] = v['cloud-profile']
if 'database' in v:
database_file = os.path.join(dir, 'database')
files[database_file] = v['database']
del files[f]

es.enter_context(
Expand Down

0 comments on commit bee7327

Please sign in to comment.