1.1 --- a/src/test/kotlin/de/uapcore/lightpit/vcs/HgConnectorTest.kt Mon Jul 17 14:45:42 2023 +0200 1.2 +++ b/src/test/kotlin/de/uapcore/lightpit/vcs/HgConnectorTest.kt Tue Jul 18 18:05:49 2023 +0200 1.3 @@ -26,13 +26,33 @@ 1.4 1.5 package de.uapcore.lightpit.vcs 1.6 1.7 -import kotlin.test.Test 1.8 -import kotlin.test.assertFalse 1.9 -import kotlin.test.assertTrue 1.10 +import kotlin.io.path.Path 1.11 +import kotlin.io.path.absolutePathString 1.12 +import kotlin.io.path.exists 1.13 +import kotlin.io.path.moveTo 1.14 +import kotlin.test.* 1.15 1.16 class HgConnectorTest { 1.17 1.18 private val testee = HgConnector("/usr/bin/hg") 1.19 + private val testRepoPath = Path("src/test/resources/test-repo") 1.20 + 1.21 + @BeforeTest 1.22 + fun prepareTestRepo() { 1.23 + assertTrue(testRepoPath.exists(), "Test must be run from the project root.") 1.24 + val hg = testRepoPath.resolve("hg") 1.25 + val dothg = testRepoPath.resolve(".hg") 1.26 + assertTrue(hg.exists(), "hg dir not found, maybe a previous execution did not terminated cleanly.") 1.27 + assertFalse(dothg.exists(), ".hg dir found, maybe a previous execution did not terminated cleanly.") 1.28 + hg.moveTo(dothg) 1.29 + } 1.30 + 1.31 + @AfterTest 1.32 + fun cleanup() { 1.33 + val hg = testRepoPath.resolve("hg") 1.34 + val dothg = testRepoPath.resolve(".hg") 1.35 + dothg.moveTo(hg) 1.36 + } 1.37 1.38 @Test 1.39 fun checkAvailability() { 1.40 @@ -43,4 +63,25 @@ 1.41 fun checkAvailabilityFalse() { 1.42 assertFalse(HgConnector("/bin/false").checkAvailability()) 1.43 } 1.44 + 1.45 + @Test 1.46 + fun readCommitLog() { 1.47 + val result = testee.readCommitLog(testRepoPath.absolutePathString()) 1.48 + assertTrue(result is VcsConnectorResult.Success) 1.49 + 1.50 + assertContentEquals( 1.51 + listOf( 1.52 + CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 50, "here we fix #50"), 1.53 + CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 30, "here we fix #50"), 1.54 + CommitRef( 1.55 + "ed7134e5f4ce278c4f62798fb9f96129be2b132b", 1.56 + 1337, 1.57 + "commit with a #non-ref, relates to #wrong ref but still fixes #1337" 1.58 + ), 1.59 + CommitRef("74d770da3c80c0c3fc1fb7e44fb710d665127dfe", 47, "a change with commitref in body"), 1.60 + CommitRef("9a14e5628bdf2d578f3385d78022ddcaf23d1abb", 47, "add test file - relates to #47") 1.61 + ), 1.62 + result.content 1.63 + ) 1.64 + } 1.65 } 1.66 \ No newline at end of file