mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-11 11:04:10 +02:00
Better error messages for --convert, closes #363
This commit is contained in:
parent
7d928f8308
commit
9dcb099905
2 changed files with 37 additions and 0 deletions
|
|
@ -472,6 +472,32 @@ def test_insert_convert_row_modifying_in_place(db_path):
|
|||
assert rows == [{"name": "Azi", "is_chicken": 1}]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"options,expected_error",
|
||||
(
|
||||
(
|
||||
["--text", "--convert", "1"],
|
||||
"Error: --convert must return dict or iterator\n",
|
||||
),
|
||||
(["--convert", "1"], "Error: Rows must all be dictionaries, got: 1\n"),
|
||||
),
|
||||
)
|
||||
def test_insert_convert_error_messages(db_path, options, expected_error):
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
[
|
||||
"insert",
|
||||
db_path,
|
||||
"rows",
|
||||
"-",
|
||||
]
|
||||
+ options,
|
||||
input='{"name": "Azi"}',
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
assert result.output == expected_error
|
||||
|
||||
|
||||
def test_insert_streaming_batch_size_1(db_path):
|
||||
# https://github.com/simonw/sqlite-utils/issues/364
|
||||
# Streaming with --batch-size 1 should commit on each record
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue