(log_file: Path, resp_url: str, paste_url: str, max_byte: int | None)
| 86 | @given(paste_url=urls, resp_url=urls, max_byte=max_bytes) |
| 87 | @settings(max_examples=3, suppress_health_check=[HealthCheck.function_scoped_fixture]) |
| 88 | def test_truncation(log_file: Path, resp_url: str, paste_url: str, max_byte: int | None) -> None: |
| 89 | content = b'A' * 50 + b'B' * 80 |
| 90 | log_file.write_bytes(content) |
| 91 | fake_response = BytesIO(resp_url.encode()) |
| 92 | |
| 93 | exptected_byte = len(content) if max_byte is None else max_byte |
| 94 | |
| 95 | with ( |
| 96 | patch('archinstall.lib.log.logger._path', new=log_file.parent), |
| 97 | patch('urllib.request.urlopen', return_value=fake_response) as mock_open, |
| 98 | ): |
| 99 | _ = share_install_log(paste_url, max_byte) |
| 100 | req = mock_open.call_args[0][0] |
| 101 | assert len(req.data) == exptected_byte |
| 102 | assert req.data == content[-exptected_byte:] |
| 103 | |
| 104 | |
| 105 | @given(paste_url=urls, max_byte=max_bytes) |
nothing calls this directly
no test coverage detected