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

changeset 282
c112fad21bf6
parent 281
c15b9555ecf3
child 283
ea6181255423
     1.1 --- a/src/test/kotlin/de/uapcore/lightpit/vcs/HgConnectorTest.kt	Sat Jul 22 11:32:27 2023 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,87 +0,0 @@
     1.4 -/*
     1.5 - * Copyright 2023 Mike Becker. All rights reserved.
     1.6 - *
     1.7 - * Redistribution and use in source and binary forms, with or without
     1.8 - * modification, are permitted provided that the following conditions are met:
     1.9 - *
    1.10 - * 1. Redistributions of source code must retain the above copyright
    1.11 - * notice, this list of conditions and the following disclaimer.
    1.12 - *
    1.13 - * 2. Redistributions in binary form must reproduce the above copyright
    1.14 - * notice, this list of conditions and the following disclaimer in the
    1.15 - * documentation and/or other materials provided with the distribution.
    1.16 - *
    1.17 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.18 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.19 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    1.20 - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    1.21 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.22 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    1.23 - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    1.24 - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    1.25 - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.26 - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.27 - *
    1.28 - */
    1.29 -
    1.30 -package de.uapcore.lightpit.vcs
    1.31 -
    1.32 -import kotlin.io.path.Path
    1.33 -import kotlin.io.path.absolutePathString
    1.34 -import kotlin.io.path.exists
    1.35 -import kotlin.io.path.moveTo
    1.36 -import kotlin.test.*
    1.37 -
    1.38 -class HgConnectorTest {
    1.39 -
    1.40 -    private val testee = HgConnector("/usr/bin/hg")
    1.41 -    private val testRepoPath = Path("src/test/resources/test-repo")
    1.42 -
    1.43 -    @BeforeTest
    1.44 -    fun prepareTestRepo() {
    1.45 -        assertTrue(testRepoPath.exists(), "Test must be run from the project root.")
    1.46 -        val hg = testRepoPath.resolve("hg")
    1.47 -        val dothg = testRepoPath.resolve(".hg")
    1.48 -        assertTrue(hg.exists(), "hg dir not found, maybe a previous execution did not terminated cleanly.")
    1.49 -        assertFalse(dothg.exists(), ".hg dir found, maybe a previous execution did not terminated cleanly.")
    1.50 -        hg.moveTo(dothg)
    1.51 -    }
    1.52 -
    1.53 -    @AfterTest
    1.54 -    fun cleanup() {
    1.55 -        val hg = testRepoPath.resolve("hg")
    1.56 -        val dothg = testRepoPath.resolve(".hg")
    1.57 -        dothg.moveTo(hg)
    1.58 -    }
    1.59 -
    1.60 -    @Test
    1.61 -    fun checkAvailability() {
    1.62 -        assertTrue(testee.checkAvailability())
    1.63 -    }
    1.64 -
    1.65 -    @Test
    1.66 -    fun checkAvailabilityFalse() {
    1.67 -        assertFalse(HgConnector("/bin/false").checkAvailability())
    1.68 -    }
    1.69 -
    1.70 -    @Test
    1.71 -    fun readCommitLog() {
    1.72 -        val result = testee.readCommitLog(testRepoPath.absolutePathString())
    1.73 -        assertTrue(result is VcsConnectorResult.Success)
    1.74 -
    1.75 -        assertContentEquals(
    1.76 -            listOf(
    1.77 -                CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 50, "here we fix #50"),
    1.78 -                CommitRef("cf9f5982ddeb28c7f695dc547fe73abf5460016f", 30, "here we fix #50"),
    1.79 -                CommitRef(
    1.80 -                    "ed7134e5f4ce278c4f62798fb9f96129be2b132b",
    1.81 -                    1337,
    1.82 -                    "commit with a #non-ref, relates to #wrong ref but still fixes #1337"
    1.83 -                ),
    1.84 -                CommitRef("74d770da3c80c0c3fc1fb7e44fb710d665127dfe", 47, "a change with commitref in body"),
    1.85 -                CommitRef("9a14e5628bdf2d578f3385d78022ddcaf23d1abb", 47, "add test file - relates to #47")
    1.86 -            ),
    1.87 -            result.content
    1.88 -        )
    1.89 -    }
    1.90 -}
    1.91 \ No newline at end of file

mercurial