Jack Rosenthal | 46e24bc | 2023-04-17 12:25:41 -0600 | [diff] [blame] | 1 | # Copyright 2023 The ChromiumOS Authors |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Tests for generate_query_docs.py.""" |
| 6 | |
| 7 | from chromite.scripts import generate_query_docs |
| 8 | |
| 9 | |
| 10 | def test_generated_contents(tmp_path): |
| 11 | """Test the output file matches the generated contents.""" |
| 12 | # pylint: disable=protected-access |
| 13 | current_file = generate_query_docs._DEFAULT_OUTPUT |
| 14 | current_contents = current_file.read_text(encoding="utf-8") |
| 15 | |
| 16 | new_file = tmp_path / "output.md" |
| 17 | generate_query_docs.main(["-o", str(new_file)]) |
| 18 | new_contents = new_file.read_text(encoding="utf-8") |
| 19 | |
| 20 | assert current_contents == new_contents, ( |
| 21 | f"{current_file} needs regenerated. Please run " |
| 22 | "scripts/generate_query_docs.", |
| 23 | ) |