|
| 1 | +from unittesting import DeferrableTestCase |
| 2 | +from GitSavvy.tests.mockito import when, verify |
| 3 | +from GitSavvy.tests.parameterized import parameterized as p |
| 4 | + |
| 5 | +from GitSavvy.core.git_mixins.history import HistoryMixin |
| 6 | + |
| 7 | + |
| 8 | +examples = [ |
| 9 | + ("from commit to working dir", "abc", None, ["abc", None]), |
| 10 | + ("from commit to commit", "abc", "def", ["abc", "def"]), |
| 11 | + ("from commit to commit", "abc", "HEAD", ["abc", "HEAD"]), |
| 12 | + ("from working dir to commit", None, "def", ["-R", "def"]), |
| 13 | + ("from working dir to HEAD", None, "HEAD", ["-R", "HEAD"]), |
| 14 | +] |
| 15 | + |
| 16 | + |
| 17 | +class TestDescribeGraphLine(DeferrableTestCase): |
| 18 | + @p.expand(examples) |
| 19 | + def test_no_context_diff_logic(self, _, base, target, cmd): |
| 20 | + test = HistoryMixin() |
| 21 | + when(test, strict=False).git("diff", ...).thenReturn("irrelevant") |
| 22 | + test.no_context_diff(base, target) |
| 23 | + common = ["diff", "--no-color", "-U0"] |
| 24 | + verify(test).git(*(common + cmd)) |
| 25 | + |
| 26 | + def test_no_context_diff_add_file_if_given(self): |
| 27 | + test = HistoryMixin() |
| 28 | + when(test, strict=False).git("diff", ...).thenReturn("irrelevant") |
| 29 | + test.no_context_diff("a", "b", "foofile.py") |
| 30 | + common = ["diff", "--no-color", "-U0"] |
| 31 | + cmd = ["a", "b", "--", "foofile.py"] |
| 32 | + verify(test).git(*(common + cmd)) |
0 commit comments