mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-10 18:44:20 +02:00
--stop-after option, closes #561
This commit is contained in:
parent
9d38925cde
commit
8c739558f7
4 changed files with 43 additions and 0 deletions
|
|
@ -229,6 +229,31 @@ def test_insert_csv_tsv(content, options, db_path, tmpdir):
|
|||
assert [{"foo": "1", "bar": "2", "baz": "cat,dog"}] == list(db["data"].rows)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"input,args",
|
||||
(
|
||||
(
|
||||
json.dumps(
|
||||
[{"name": "One"}, {"name": "Two"}, {"name": "Three"}, {"name": "Four"}]
|
||||
),
|
||||
[],
|
||||
),
|
||||
("name\nOne\nTwo\nThree\nFour\n", ["--csv"]),
|
||||
),
|
||||
)
|
||||
def test_insert_stop_after(tmpdir, input, args):
|
||||
db_path = str(tmpdir / "data.db")
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
["insert", db_path, "rows", "-", "--stop-after", "2"] + args,
|
||||
input=input,
|
||||
)
|
||||
assert 0 == result.exit_code
|
||||
assert [{"name": "One"}, {"name": "Two"}] == list(
|
||||
Database(db_path).query("select * from rows")
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"options",
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue