mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Merge branch 'main' into 1.0-dev
This commit is contained in:
commit
b8fc8e2cd7
7 changed files with 103 additions and 19 deletions
|
|
@ -2,6 +2,7 @@ from click.testing import CliRunner
|
|||
from datasette import cli
|
||||
from unittest import mock
|
||||
import os
|
||||
import pathlib
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
@ -128,3 +129,55 @@ def test_publish_heroku_plugin_secrets(
|
|||
mock.call(["heroku", "builds:create", "-a", "f", "--include-vcs-ignore"]),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.serial
|
||||
@mock.patch("shutil.which")
|
||||
@mock.patch("datasette.publish.heroku.check_output")
|
||||
@mock.patch("datasette.publish.heroku.call")
|
||||
def test_publish_heroku_generate_dir(
|
||||
mock_call, mock_check_output, mock_which, tmp_path_factory
|
||||
):
|
||||
mock_which.return_value = True
|
||||
mock_check_output.side_effect = lambda s: {
|
||||
"['heroku', 'plugins']": b"heroku-builds",
|
||||
}[repr(s)]
|
||||
runner = CliRunner()
|
||||
os.chdir(tmp_path_factory.mktemp("runner"))
|
||||
with open("test.db", "w") as fp:
|
||||
fp.write("data")
|
||||
output = str(tmp_path_factory.mktemp("generate_dir") / "output")
|
||||
result = runner.invoke(
|
||||
cli.cli,
|
||||
[
|
||||
"publish",
|
||||
"heroku",
|
||||
"test.db",
|
||||
"--generate-dir",
|
||||
output,
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
path = pathlib.Path(output)
|
||||
assert path.exists()
|
||||
file_names = {str(r.relative_to(path)) for r in path.glob("*")}
|
||||
assert file_names == {
|
||||
"requirements.txt",
|
||||
"bin",
|
||||
"runtime.txt",
|
||||
"Procfile",
|
||||
"test.db",
|
||||
}
|
||||
for name, expected in (
|
||||
("requirements.txt", "datasette"),
|
||||
("runtime.txt", "python-3.11.0"),
|
||||
(
|
||||
"Procfile",
|
||||
(
|
||||
"web: datasette serve --host 0.0.0.0 -i test.db "
|
||||
"--cors --port $PORT --inspect-file inspect-data.json"
|
||||
),
|
||||
),
|
||||
):
|
||||
with open(path / name) as fp:
|
||||
assert fp.read().strip() == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue