Skip to content

Commit fbc47db

Browse files
committed
Add tests
1 parent c92ad77 commit fbc47db

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sqlalchemy
2+
import pytest
3+
from testcontainers.cratedb import CrateDBContainer
4+
5+
6+
@pytest.mark.parametrize("version", ["5.9", "5.10", "6.0", "latest"])
7+
def test_docker_run_cratedb(version: str):
8+
with CrateDBContainer(f"crate:{version}") as container:
9+
engine = sqlalchemy.create_engine(container.get_connection_url())
10+
with engine.begin() as conn:
11+
result = conn.execute(sqlalchemy.text("select 1+2+3+4+5"))
12+
sum_result = result.fetchone()[0]
13+
assert sum_result == 15
14+
15+
16+
@pytest.mark.parametrize(
17+
"opts, expected",
18+
[
19+
pytest.param(
20+
{"indices.breaker.total.limit": "90%"},
21+
(
22+
"-Cdiscovery.type=single-node "
23+
"-Cnode.attr.storage=hot "
24+
"-Cpath.repo=/tmp/snapshots "
25+
"-Cindices.breaker.total.limit=90%"
26+
),
27+
id="add_cmd_option",
28+
),
29+
pytest.param(
30+
{"discovery.type": "zen", "indices.breaker.total.limit": "90%"},
31+
(
32+
"-Cdiscovery.type=zen "
33+
"-Cnode.attr.storage=hot "
34+
"-Cpath.repo=/tmp/snapshots "
35+
"-Cindices.breaker.total.limit=90%"
36+
),
37+
id="override_defaults",
38+
),
39+
],
40+
)
41+
def test_build_command(opts, expected):
42+
db = CrateDBContainer(cmd_opts=opts)
43+
assert db._command == expected

0 commit comments

Comments
 (0)