diff --git a/datasette/publish/now.py b/datasette/publish/now.py index 5c5a3967..f2e3b9c2 100644 --- a/datasette/publish/now.py +++ b/datasette/publish/now.py @@ -92,8 +92,10 @@ def publish_subcommand(publish): # I couldn't get --target=production working, so I call # 'now alias' with arguments directly instead - but that # means I need to figure out what URL it was deployed to. - for single_alias in alias: - # Because --alias can be specified multiple times - run(["now", "alias", deployment_url, single_alias]) + for single_alias in alias: # --alias can be specified multiple times + args = ["now", "alias", deployment_url, single_alias] + if token: + args.append("--token={}".format(token)) + run(args) else: print(deployment_url.decode("latin1")) diff --git a/tests/test_publish_now.py b/tests/test_publish_now.py index aa6ef7cf..dca57654 100644 --- a/tests/test_publish_now.py +++ b/tests/test_publish_now.py @@ -63,12 +63,40 @@ def test_publish_now_multiple_aliases(mock_run, mock_which): open("test.db", "w").write("data") runner.invoke( cli.cli, - ["publish", "now", "test.db", "--alias", "alias1", "--alias", "alias2"], + [ + "publish", + "now", + "test.db", + "--token", + "XXX", + "--alias", + "alias1", + "--alias", + "alias2", + ], ) mock_run.assert_has_calls( [ - mock.call("now", stdout=subprocess.PIPE), - mock.call(["now", "alias", b"https://demo.example.com/", "alias1"]), - mock.call(["now", "alias", b"https://demo.example.com/", "alias2"]), + mock.call(["now", "--token", "XXX"], stdout=subprocess.PIPE), + mock.call( + [ + "now", + "alias", + b"https://demo.example.com/", + "alias1", + "--token", + "XXX", + ] + ), + mock.call( + [ + "now", + "alias", + b"https://demo.example.com/", + "alias2", + "--token", + "XXX", + ] + ), ] )