src/test/kotlin/de/uapcore/lightpit/vcs/HgConnectorTest.kt

changeset 280
12b898531d1a
parent 279
d73537b925af
equal deleted inserted replaced
279:d73537b925af 280:12b898531d1a
24 * 24 *
25 */ 25 */
26 26
27 package de.uapcore.lightpit.vcs 27 package de.uapcore.lightpit.vcs
28 28
29 import kotlin.test.Test 29 import kotlin.io.path.Path
30 import kotlin.test.assertFalse 30 import kotlin.io.path.absolutePathString
31 import kotlin.test.assertTrue 31 import kotlin.io.path.exists
32 import kotlin.io.path.moveTo
33 import kotlin.test.*
32 34
33 class HgConnectorTest { 35 class HgConnectorTest {
34 36
35 private val testee = HgConnector("/usr/bin/hg") 37 private val testee = HgConnector("/usr/bin/hg")
38 private val testRepoPath = Path("src/test/resources/test-repo")
39
40 @BeforeTest
41 fun prepareTestRepo() {
42 assertTrue(testRepoPath.exists(), "Test must be run from the project root.")
43 val hg = testRepoPath.resolve("hg")
44 val dothg = testRepoPath.resolve(".hg")
45 assertTrue(hg.exists(), "hg dir not found, maybe a previous execution did not terminated cleanly.")
46 assertFalse(dothg.exists(), ".hg dir found, maybe a previous execution did not terminated cleanly.")
47 hg.moveTo(dothg)
48 }
49
50 @AfterTest
51 fun cleanup() {
52 val hg = testRepoPath.resolve("hg")
53 val dothg = testRepoPath.resolve(".hg")
54 dothg.moveTo(hg)
55 }
36 56
37 @Test 57 @Test
38 fun checkAvailability() { 58 fun checkAvailability() {
39 assertTrue(testee.checkAvailability()) 59 assertTrue(testee.checkAvailability())
40 } 60 }
41 61
42 @Test 62 @Test
43 fun checkAvailabilityFalse() { 63 fun checkAvailabilityFalse() {
44 assertFalse(HgConnector("/bin/false").checkAvailability()) 64 assertFalse(HgConnector("/bin/false").checkAvailability())
45 } 65 }
66
67 @Test
68 fun readCommitLog() {
69 val result = testee.readCommitLog(testRepoPath.absolutePathString())
70 assertTrue(result is VcsConnectorResult.Success)
71
72 assertContentEquals(
73 listOf(
74 CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 50, "here we fix #50"),
75 CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 30, "here we fix #50"),
76 CommitRef(
77 "ed7134e5f4ce278c4f62798fb9f96129be2b132b",
78 1337,
79 "commit with a #non-ref, relates to #wrong ref but still fixes #1337"
80 ),
81 CommitRef("74d770da3c80c0c3fc1fb7e44fb710d665127dfe", 47, "a change with commitref in body"),
82 CommitRef("9a14e5628bdf2d578f3385d78022ddcaf23d1abb", 47, "add test file - relates to #47")
83 ),
84 result.content
85 )
86 }
46 } 87 }

mercurial