Skip to content

Commit

Permalink
Improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
pilosus authored and amotl committed Nov 24, 2023
1 parent 57f00d2 commit 7f3a493
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cratedb_toolkit/testing/testcontainers/cratedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(

self._name = "testcontainers-cratedb"

cmd_opts = cmd_opts if cmd_opts else {}
cmd_opts = cmd_opts or {}
self._command = self._build_cmd({**self.CMD_OPTS, **cmd_opts})

self.CRATEDB_USER = user or self.CRATEDB_USER
Expand All @@ -110,7 +110,7 @@ def _build_cmd(opts: dict) -> str:
for key, val in opts.items():
if isinstance(val, bool):
val = str(val).lower()
cmd.append("-C{}={}".format(key, val))
cmd.append(f"-C{key}={val}")
return " ".join(cmd)

def _configure_ports(self) -> None:
Expand Down
33 changes: 33 additions & 0 deletions tests/testing/test_testcontainers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest

from cratedb_toolkit.testing.testcontainers.cratedb import CrateDBContainer


@pytest.mark.parametrize(
"opts, expected",
[
pytest.param(
{"indices.breaker.total.limit": "90%"},
(
"-Cdiscovery.type=single-node "
"-Cnode.attr.storage=hot "
"-Cpath.repo=/tmp/snapshots "
"-Cindices.breaker.total.limit=90%"
),
id="add_cmd_option",
),
pytest.param(
{"discovery.type": "zen", "indices.breaker.total.limit": "90%"},
(
"-Cdiscovery.type=zen "
"-Cnode.attr.storage=hot "
"-Cpath.repo=/tmp/snapshots "
"-Cindices.breaker.total.limit=90%"
),
id="override_defaults",
),
],
)
def test_build_command(opts, expected):
db = CrateDBContainer(cmd_opts=opts)
assert db._command == expected

0 comments on commit 7f3a493

Please sign in to comment.