We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
command to check lock file
<!-- Checked checkbox should look like this: [x] -->
- [X] I have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.

## Issue

Would it be possible to add a `poetry check` command (oh, I see you'e used that already, maybe the command could be extended or have a `poetry lock --check`?) that will return zero if the current poetry.lock is both correct w.r.t. the pyproject.toml (ie: packages match) *and* that it matches the output of `poetry lock`.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `poetry/console/commands/lock.py`
Content:
```
1 from cleo.helpers import option
2 
3 from .installer_command import InstallerCommand
4 
5 
6 class LockCommand(InstallerCommand):
7 
8     name = "lock"
9     description = "Locks the project dependencies."
10 
11     options = [
12         option(
13             "no-update", None, "Do not update locked versions, only refresh lock file."
14         ),
15     ]
16 
17     help = """
18 The <info>lock</info> command reads the <comment>pyproject.toml</> file from the
19 current directory, processes it, and locks the dependencies in the <comment>poetry.lock</>
20 file.
21 
22 <info>poetry lock</info>
23 """
24 
25     loggers = ["poetry.repositories.pypi_repository"]
26 
27     def handle(self) -> int:
28         self._installer.use_executor(
29             self.poetry.config.get("experimental.new-installer", False)
30         )
31 
32         self._installer.lock(update=not self.option("no-update"))
33 
34         return self._installer.run()
35
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/poetry/console/commands/lock.py b/poetry/console/commands/lock.py
--- a/poetry/console/commands/lock.py
+++ b/poetry/console/commands/lock.py
@@ -12,6 +12,12 @@
         option(
             "no-update", None, "Do not update locked versions, only refresh lock file."
         ),
+        option(
+            "check",
+            None,
+            "Check that the <comment>poetry.lock</> file corresponds to the current version "
+            "of <comment>pyproject.toml</>.",
+        ),
     ]
 
     help = """
@@ -29,6 +35,13 @@
             self.poetry.config.get("experimental.new-installer", False)
         )
 
+        if self.option("check"):
+            return (
+                0
+                if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh()
+                else 1
+            )
+
         self._installer.lock(update=not self.option("no-update"))
 
         return self._installer.run()

{"golden_diff": "diff --git a/poetry/console/commands/lock.py b/poetry/console/commands/lock.py\n--- a/poetry/console/commands/lock.py\n+++ b/poetry/console/commands/lock.py\n@@ -12,6 +12,12 @@\n         option(\n             \"no-update\", None, \"Do not update locked versions, only refresh lock file.\"\n         ),\n+        option(\n+            \"check\",\n+            None,\n+            \"Check that the <comment>poetry.lock</> file corresponds to the current version \"\n+            \"of <comment>pyproject.toml</>.\",\n+        ),\n     ]\n \n     help = \"\"\"\n@@ -29,6 +35,13 @@\n             self.poetry.config.get(\"experimental.new-installer\", False)\n         )\n \n+        if self.option(\"check\"):\n+            return (\n+                0\n+                if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh()\n+                else 1\n+            )\n+\n         self._installer.lock(update=not self.option(\"no-update\"))\n \n         return self._installer.run()\n", "issue": "command to check lock file\n<!-- Checked checkbox should look like this: [x] -->\r\n- [X] I have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.\r\n\r\n## Issue\r\n\r\nWould it be possible to add a `poetry check` command (oh, I see you'e used that already, maybe the command could be extended or have a `poetry lock --check`?) that will return zero if the current poetry.lock is both correct w.r.t. the pyproject.toml (ie: packages match) *and* that it matches the output of `poetry lock`.\r\n\n", "before_files": [{"content": "from cleo.helpers import option\n\nfrom .installer_command import InstallerCommand\n\n\nclass LockCommand(InstallerCommand):\n\n    name = \"lock\"\n    description = \"Locks the project dependencies.\"\n\n    options = [\n        option(\n            \"no-update\", None, \"Do not update locked versions, only refresh lock file.\"\n        ),\n    ]\n\n    help = \"\"\"\nThe <info>lock</info> command reads the <comment>pyproject.toml</> file from the\ncurrent directory, processes it, and locks the dependencies in the <comment>poetry.lock</>\nfile.\n\n<info>poetry lock</info>\n\"\"\"\n\n    loggers = [\"poetry.repositories.pypi_repository\"]\n\n    def handle(self) -> int:\n        self._installer.use_executor(\n            self.poetry.config.get(\"experimental.new-installer\", False)\n        )\n\n        self._installer.lock(update=not self.option(\"no-update\"))\n\n        return self._installer.run()\n", "path": "poetry/console/commands/lock.py"}], "after_files": [{"content": "from cleo.helpers import option\n\nfrom .installer_command import InstallerCommand\n\n\nclass LockCommand(InstallerCommand):\n\n    name = \"lock\"\n    description = \"Locks the project dependencies.\"\n\n    options = [\n        option(\n            \"no-update\", None, \"Do not update locked versions, only refresh lock file.\"\n        ),\n        option(\n            \"check\",\n            None,\n            \"Check that the <comment>poetry.lock</> file corresponds to the current version \"\n            \"of <comment>pyproject.toml</>.\",\n        ),\n    ]\n\n    help = \"\"\"\nThe <info>lock</info> command reads the <comment>pyproject.toml</> file from the\ncurrent directory, processes it, and locks the dependencies in the <comment>poetry.lock</>\nfile.\n\n<info>poetry lock</info>\n\"\"\"\n\n    loggers = [\"poetry.repositories.pypi_repository\"]\n\n    def handle(self) -> int:\n        self._installer.use_executor(\n            self.poetry.config.get(\"experimental.new-installer\", False)\n        )\n\n        if self.option(\"check\"):\n            return (\n                0\n                if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh()\n                else 1\n            )\n\n        self._installer.lock(update=not self.option(\"no-update\"))\n\n        return self._installer.run()\n", "path": "poetry/console/commands/lock.py"}]}