--secret command for datasette publish

Closes #787
This commit is contained in:
Simon Willison 2020-06-11 09:02:03 -07:00 committed by GitHub
commit 98632f0a87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 58 additions and 14 deletions

View file

@ -15,7 +15,7 @@ FROM python:3.8
COPY . /app
WORKDIR /app
ENV DATASETTE_SECRET 'sekrit'
RUN pip install -U datasette
RUN datasette inspect test.db --inspect-file inspect-data.json
ENV PORT {port}
@ -33,7 +33,7 @@ def test_package(mock_call, mock_which):
mock_call.side_effect = capture
with runner.isolated_filesystem():
open("test.db", "w").write("data")
result = runner.invoke(cli.cli, ["package", "test.db"])
result = runner.invoke(cli.cli, ["package", "test.db", "--secret", "sekrit"])
assert 0 == result.exit_code
mock_call.assert_has_calls([mock.call(["docker", "build", "."])])
assert EXPECTED_DOCKERFILE.format(port=8001) == capture.captured
@ -48,6 +48,8 @@ def test_package_with_port(mock_call, mock_which):
runner = CliRunner()
with runner.isolated_filesystem():
open("test.db", "w").write("data")
result = runner.invoke(cli.cli, ["package", "test.db", "-p", "8080"])
result = runner.invoke(
cli.cli, ["package", "test.db", "-p", "8080", "--secret", "sekrit"]
)
assert 0 == result.exit_code
assert EXPECTED_DOCKERFILE.format(port=8080) == capture.captured