diff -r d73537b925af -r 12b898531d1a src/test/kotlin/de/uapcore/lightpit/vcs/HgConnectorTest.kt --- a/src/test/kotlin/de/uapcore/lightpit/vcs/HgConnectorTest.kt Mon Jul 17 14:45:42 2023 +0200 +++ b/src/test/kotlin/de/uapcore/lightpit/vcs/HgConnectorTest.kt Tue Jul 18 18:05:49 2023 +0200 @@ -26,13 +26,33 @@ package de.uapcore.lightpit.vcs -import kotlin.test.Test -import kotlin.test.assertFalse -import kotlin.test.assertTrue +import kotlin.io.path.Path +import kotlin.io.path.absolutePathString +import kotlin.io.path.exists +import kotlin.io.path.moveTo +import kotlin.test.* class HgConnectorTest { private val testee = HgConnector("/usr/bin/hg") + private val testRepoPath = Path("src/test/resources/test-repo") + + @BeforeTest + fun prepareTestRepo() { + assertTrue(testRepoPath.exists(), "Test must be run from the project root.") + val hg = testRepoPath.resolve("hg") + val dothg = testRepoPath.resolve(".hg") + assertTrue(hg.exists(), "hg dir not found, maybe a previous execution did not terminated cleanly.") + assertFalse(dothg.exists(), ".hg dir found, maybe a previous execution did not terminated cleanly.") + hg.moveTo(dothg) + } + + @AfterTest + fun cleanup() { + val hg = testRepoPath.resolve("hg") + val dothg = testRepoPath.resolve(".hg") + dothg.moveTo(hg) + } @Test fun checkAvailability() { @@ -43,4 +63,25 @@ fun checkAvailabilityFalse() { assertFalse(HgConnector("/bin/false").checkAvailability()) } + + @Test + fun readCommitLog() { + val result = testee.readCommitLog(testRepoPath.absolutePathString()) + assertTrue(result is VcsConnectorResult.Success) + + assertContentEquals( + listOf( + CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 50, "here we fix #50"), + CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 30, "here we fix #50"), + CommitRef( + "ed7134e5f4ce278c4f62798fb9f96129be2b132b", + 1337, + "commit with a #non-ref, relates to #wrong ref but still fixes #1337" + ), + CommitRef("74d770da3c80c0c3fc1fb7e44fb710d665127dfe", 47, "a change with commitref in body"), + CommitRef("9a14e5628bdf2d578f3385d78022ddcaf23d1abb", 47, "add test file - relates to #47") + ), + result.content + ) + } } \ No newline at end of file