Test git.commit two ways: 1) First using git.add, then git.commit 2) Using git.commit with the 'filename' argument to skip staging
(self)
| 316 | |
| 317 | @pytest.mark.slow_test |
| 318 | def test_commit(self): |
| 319 | """ |
| 320 | Test git.commit two ways: |
| 321 | 1) First using git.add, then git.commit |
| 322 | 2) Using git.commit with the 'filename' argument to skip staging |
| 323 | """ |
| 324 | filename = "foo" |
| 325 | commit_re_prefix = r"^\[master [0-9a-f]+\] " |
| 326 | # Add a line |
| 327 | with salt.utils.files.fopen(os.path.join(self.repo, filename), "a") as fp_: |
| 328 | fp_.write("Added a line\n") |
| 329 | # Stage the file |
| 330 | self.run_function("git.add", [self.repo, filename]) |
| 331 | # Commit the staged file |
| 332 | commit_msg = f"Add a line to {filename}" |
| 333 | ret = self.run_function("git.commit", [self.repo, f'"{commit_msg}"']) |
| 334 | # Make sure the expected line is in the output |
| 335 | self.assertTrue(bool(re.search(commit_re_prefix, ret))) |
| 336 | self.assertTrue(bool(commit_msg in ret)) |
| 337 | # Add another line |
| 338 | with salt.utils.files.fopen(os.path.join(self.repo, filename), "a") as fp_: |
| 339 | fp_.write("Added another line\n") |
| 340 | # Commit the second file without staging |
| 341 | commit_msg = f"Add another line to {filename}" |
| 342 | ret = self.run_function( |
| 343 | "git.commit", [self.repo, f'"{commit_msg}"'], filename=filename |
| 344 | ) |
| 345 | self.assertTrue(bool(re.search(commit_re_prefix, ret))) |
| 346 | self.assertTrue(bool(commit_msg in ret)) |
| 347 | |
| 348 | @pytest.mark.slow_test |
| 349 | def test_config(self): |
nothing calls this directly
no test coverage detected