diff --git a/tests/lib/test_detected_commit.py b/tests/lib/test_detected_commit.py new file mode 100644 index 0000000..e9a2b1f --- /dev/null +++ b/tests/lib/test_detected_commit.py @@ -0,0 +1,57 @@ +import pytest +from repo_cloner.lib import DetectedCommit + + +@pytest.fixture +def det_dict(): + return { + 'commit': "aa5056610ff57f73bae9633a985c6a8e41f3bc23", + 'abbrev': "aa50566", + 'author': "Mocked Tester", + 'date': 1659604838, + 'is_tag': True, + 'tags': ["tag1", "tag2"], + 'is_branch': True, + 'branches': ["br1", "br2"], + 'log': "Test message\n\nLine 2", + } + + +@pytest.fixture +def det(det_dict): + return DetectedCommit(det_dict) + + +def test_detected_commit_dict(det_dict): + det = DetectedCommit(det_dict) + assert det.dict == det_dict + + +def test_commit(det): + assert det.commit == "aa5056610ff57f73bae9633a985c6a8e41f3bc23" + + +def test_abbrev(det): + assert det.abbrev == "aa50566" + + +def test_author(det): + assert det.author == "Mocked Tester" + + +def test_date(det): + assert det.date == "04-08-2022, 11:20:38" + + +def test_tags(det): + assert det.is_tag + assert det.tags == "tag1, tag2" + + +def test_branches(det): + assert det.is_branch + assert det.branches == "br1, br2" + + +def test_log(det): + assert det.log == "Test message\n\nLine 2"