Skip to content

Commit 75073f3

Browse files
committed
Tests for new objects command, refs #7
1 parent d8f071b commit 75073f3

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/test_objects.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from click.testing import CliRunner
2+
from sqlite_diffable import cli
3+
import pytest
4+
5+
6+
@pytest.mark.parametrize(
7+
"options,expected_output",
8+
(
9+
(
10+
[],
11+
(
12+
'\n{"id": 1, "name": "Stacey"}\n'
13+
'{"id": 2, "name": "Tilda"}\n'
14+
'{"id": 3, "name": "Bartek"}\n'
15+
),
16+
),
17+
(
18+
["--array"],
19+
(
20+
'[\n{"id": 1, "name": "Stacey"},\n'
21+
'{"id": 2, "name": "Tilda"},\n'
22+
'{"id": 3, "name": "Bartek"}\n]\n'
23+
),
24+
),
25+
),
26+
)
27+
def test_dump(one_table_db, tmpdir, options, expected_output):
28+
output_dir = tmpdir / "out"
29+
result = CliRunner().invoke(
30+
cli.cli, ["dump", one_table_db, str(output_dir), "one_table"]
31+
)
32+
assert result.exit_code == 0, result.output
33+
result2 = CliRunner().invoke(
34+
cli.cli, ["objects", str(output_dir / "one_table.ndjson")] + options
35+
)
36+
assert result2.output == expected_output

0 commit comments

Comments
 (0)