Skip to content

Commit

Permalink
Test for get_unmodified_content with revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
akaihola committed Aug 8, 2020
1 parent ab4a151 commit db6ed81
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/darker/tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
)


def test_get_unmodified_content(git_repo):
paths = git_repo.add({'my.txt': 'original content'}, commit='Initial commit')
@pytest.mark.parametrize(
'revision, expect',
[("HEAD", ["modified content"]), ("HEAD^", ["original content"]), ("HEAD~2", []),],
)
def test_get_unmodified_content(git_repo, revision, expect):
git_repo.add({"my.txt": "original content"}, commit="Initial commit")
paths = git_repo.add({"my.txt": "modified content"}, commit="Initial commit")
paths['my.txt'].write('new content')

original_content = git_get_unmodified_content(
Path("my.txt"), "HEAD", cwd=git_repo.root
Path("my.txt"), revision, cwd=git_repo.root
)

assert original_content == ['original content']
assert original_content == expect


@pytest.mark.parametrize(
Expand Down

0 comments on commit db6ed81

Please sign in to comment.