Skip to content

Commit

Permalink
test start
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftp committed Aug 1, 2024
1 parent 0a60f41 commit 78c09a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dbos_transact/dbos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@ def load_config(configFilePath: str = "dbos-config.yaml") -> ConfigFile:
f'dbos-config.yaml specifies invalid language { data["language"] }'
)

if "runtimeConfig" not in data or "start" not in data["runtimeConfig"]:
raise DBOSInitializationError(f"dbos-config.yaml must specify a start command")

# Return data as ConfigFile type
return data # type: ignore
25 changes: 25 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def test_valid_config(mocker):
mock_config = """
name: "some app"
language: "python"
runtimeConfig:
start:
- "python3 main.py"
database:
hostname: 'some host'
port: 1234
Expand Down Expand Up @@ -161,3 +164,25 @@ def test_config_bad_language(mocker):
dbos_transact.dbos_config.load_config(mock_filename)

assert "invalid language" in str(exc_info.value)


def test_config_no_start(mocker):
mock_config = """
name: "some app"
language: python
database:
hostname: 'some host'
port: 1234
username: 'some user'
password: abc123
app_db_name: 'some db'
connectionTimeoutMillis: 3000
"""
mocker.patch(
"builtins.open", side_effect=generate_mock_open(mock_filename, mock_config)
)

with pytest.raises(DBOSInitializationError) as exc_info:
dbos_transact.dbos_config.load_config(mock_filename)

assert "start command" in str(exc_info.value)

0 comments on commit 78c09a7

Please sign in to comment.