--no-skip-false option, plus docs - closes #527

This commit is contained in:
Simon Willison 2023-05-08 14:03:20 -07:00
commit e0ec4c3451
4 changed files with 34 additions and 0 deletions

View file

@ -626,3 +626,30 @@ def test_convert_initialization_pattern(fresh_db_and_path):
assert list(db["names"].rows) == [
{"id": 1, "name": "17"},
]
@pytest.mark.parametrize(
"no_skip_false,expected",
(
(True, 1),
(False, 0),
),
)
def test_convert_no_skip_false(fresh_db_and_path, no_skip_false, expected):
db, db_path = fresh_db_and_path
args = [
"convert",
db_path,
"t",
"x",
"-",
]
if no_skip_false:
args.append("--no-skip-false")
db["t"].insert_all([{"x": 0}, {"x": 1}])
assert db["t"].get(1)["x"] == 0
assert db["t"].get(2)["x"] == 1
result = CliRunner().invoke(cli.cli, args, input="value + 1")
assert 0 == result.exit_code, result.output
assert db["t"].get(1)["x"] == expected
assert db["t"].get(2)["x"] == 2