{"html_url": "https://github.com/simonw/datasette/issues/1272#issuecomment-1199115002", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1272", "id": 1199115002, "node_id": "IC_kwDOBm6k_c5HeQr6", "user": {"value": 37748899, "label": "xmichele"}, "created_at": "2022-07-29T10:22:58Z", "updated_at": "2022-07-29T10:22:58Z", "author_association": "NONE", "body": "> test_dockerfile.py\r\n\r\n\r\n\r\n> I'm skipping this for the moment because the new Dockerfile shape introduced in [#1249 (comment)](https://github.com/simonw/datasette/issues/1249#issuecomment-804404544) isn't compatible with this technique, since it installs Datasette from PyPI rather than directly from the repo.\r\n> \r\n> Will need to change that if I want to do this unit tests thing.\r\n\r\nHello,\r\ncan't you copy in a later step directly in the output directory, e.g. COPY test_dockerfile.py /usr/lib/python*/.. or something like that ? ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 838245338, "label": "Unit tests for the Dockerfile"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1272#issuecomment-808648974", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1272", "id": 808648974, "node_id": "MDEyOklzc3VlQ29tbWVudDgwODY0ODk3NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-03-27T04:29:42Z", "updated_at": "2021-03-27T04:29:42Z", "author_association": "OWNER", "body": "I'm skipping this for the moment because the new Dockerfile shape introduced in https://github.com/simonw/datasette/issues/1249#issuecomment-804404544 isn't compatible with this technique, since it installs Datasette from PyPI rather than directly from the repo.\r\n\r\nWill need to change that if I want to do this unit tests thing.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 838245338, "label": "Unit tests for the Dockerfile"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1272#issuecomment-808647937", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1272", "id": 808647937, "node_id": "MDEyOklzc3VlQ29tbWVudDgwODY0NzkzNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-03-27T04:23:19Z", "updated_at": "2021-03-27T04:23:36Z", "author_association": "OWNER", "body": "Part of the challenge here is only running if a Docker daemon is available. I think this pattern works, in `tests/test_dockerfile.py`:\r\n```python\r\nimport httpx\r\nimport pathlib\r\nimport pytest\r\nimport subprocess\r\n\r\nroot = pathlib.Path(__file__).parent.parent\r\n\r\ndef docker_is_available():\r\n try:\r\n client = httpx.Client(\r\n transport=httpx.HTTPTransport(uds=\"/var/run/docker.sock\")\r\n )\r\n client.get(\"http://docker/info\")\r\n return True\r\n except httpx.ConnectError:\r\n return False\r\n\r\n\r\n@pytest.fixture\r\ndef build_container():\r\n assert (root / \"Dockerfile\").exists()\r\n subprocess.check_call([\r\n \"docker\", \"build\", str(root), \"-t\", \"datasette-dockerfile-test\"\r\n ])\r\n\r\n\r\n@pytest.mark.skipif(not docker_is_available(),\r\n reason=\"Docker is not available\"\r\n)\r\ndef test_dockerfile(build_container):\r\n output = subprocess.check_output([\r\n \"docker\", \"run\", \"datasette-dockerfile-test\", \"datasette\", \"--get\", \"/_memory?sql=select+1&shape=_array\"\r\n ])\r\n assert False, \"Implement better assertion here\"\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 838245338, "label": "Unit tests for the Dockerfile"}, "performed_via_github_app": null}