diff --git a/datasette_publish_now/__init__.py b/datasette_publish_now/__init__.py index bdfe0d9..8f1cb51 100644 --- a/datasette_publish_now/__init__.py +++ b/datasette_publish_now/__init__.py @@ -169,4 +169,6 @@ def now2( cmd.append("--prod") if public: cmd.append("--public") + if token: + cmd.extend(["--token", token]) run(cmd) diff --git a/tests/test_publish_now.py b/tests/test_publish_now.py index 7de0b26..fd06c5a 100644 --- a/tests/test_publish_now.py +++ b/tests/test_publish_now.py @@ -66,6 +66,28 @@ def test_publish_now_public(mock_run, mock_which): ) +@mock.patch("shutil.which") +@mock.patch("datasette_publish_now.run") +def test_publish_now_token(mock_run, mock_which): + mock_which.return_value = True + mock_run.return_value = mock.Mock(0) + runner = CliRunner() + with runner.isolated_filesystem(): + open("test.db", "w").write("data") + result = runner.invoke( + cli.cli, + ["publish", "now2", "test.db", "--project", "foo", "--token", "xyz"], + ) + assert result.exit_code == 0 + mock_run.assert_has_calls( + [ + mock.call( + ["now", "--confirm", "--no-clipboard", "--prod", "--token", "xyz"] + ), + ] + ) + + @pytest.fixture(scope="session") @mock.patch("shutil.which") @mock.patch("datasette_publish_now.run") @@ -100,7 +122,7 @@ def test_publish_now_generate(generated_app_dir): assert {"requirements.txt", "index.py", "now.json", "test.db"} == filenames -def test_publish_now_requiremens(generated_app_dir): +def test_publish_now_requirements(generated_app_dir): requirements = set( l.strip() for l in open(os.path.join(generated_app_dir, "requirements.txt")).readlines()