| 180 | |
| 181 | @pytest.mark.parametrize(*CMD_CASES) |
| 182 | def test_cmd( |
| 183 | self, |
| 184 | method: Callable[..., str], |
| 185 | expected_output: str, |
| 186 | expected_ret_code: int, |
| 187 | expected_exception: bool, |
| 188 | expected_logs: str, |
| 189 | caplog: LogCaptureFixture, |
| 190 | folder: str, |
| 191 | ): |
| 192 | with caplog.at_level(logging.INFO): |
| 193 | tf = Terraform(working_dir=current_path) |
| 194 | tf.init(folder) |
| 195 | try: |
| 196 | ret, out, _ = method(tf) |
| 197 | assert not expected_exception |
| 198 | except TerraformCommandError as e: |
| 199 | assert expected_exception |
| 200 | ret = e.returncode |
| 201 | out = e.out |
| 202 | |
| 203 | assert expected_output in out |
| 204 | assert expected_ret_code == ret |
| 205 | assert expected_logs in caplog.text |
| 206 | |
| 207 | @pytest.mark.parametrize( |
| 208 | ("folder", "variables", "var_files", "expected_output", "options"), |