diff --git a/plugins/git4idea/tests/git4idea/history/GitLogParserTest.kt b/plugins/git4idea/tests/git4idea/history/GitLogParserTest.kt index e82e89d0aa72..5c3105c76dfa 100644 --- a/plugins/git4idea/tests/git4idea/history/GitLogParserTest.kt +++ b/plugins/git4idea/tests/git4idea/history/GitLogParserTest.kt @@ -27,7 +27,6 @@ class GitLogParserTest : GitPlatformTest() { override fun setUp() { super.setUp() root = projectRoot - newRefsFormat = false } @Throws(VcsException::class) @@ -41,8 +40,8 @@ class GitLogParserTest : GitPlatformTest() { } @Throws(VcsException::class) - private fun doTestAllRecords(nameStatusOption: NameStatus) { - val expectedRecords = generateRecords() + private fun doTestAllRecords(nameStatusOption: NameStatus, newRefsFormat: Boolean = false) { + val expectedRecords = generateRecords(newRefsFormat) val option: NameStatus when (nameStatusOption) { @@ -102,14 +101,12 @@ class GitLogParserTest : GitPlatformTest() { @Throws(VcsException::class) fun test_old_refs_format() { - newRefsFormat = false doTestAllRecords(NONE) } @Throws(VcsException::class) fun test_new_refs_format() { - newRefsFormat = true - doTestAllRecords(STATUS) + doTestAllRecords(STATUS, true) } private fun doTestCustomCommitMessage(subject: String) { @@ -236,7 +233,8 @@ class GitLogParserTest : GitPlatformTest() { CHANGES } - internal class GitTestLogRecord internal constructor(private val data: Map) { + internal class GitTestLogRecord internal constructor(private val data: Map, + private val newRefsFormat: Boolean = false) { val hash: String get() = data[GitTestLogRecordInfo.HASH] as String @@ -419,15 +417,14 @@ class GitLogParserTest : GitPlatformTest() { } companion object { - internal val GIT_LOG_OPTIONS = arrayOf(HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME, COMMITTER_EMAIL, SUBJECT, BODY, PARENTS, PARENTS, RAW_BODY, REF_NAMES) - private var newRefsFormat: Boolean = false } } -private fun createTestRecord(vararg parameters: Pair): GitLogParserTest.GitTestLogRecord { +private fun createTestRecord(vararg parameters: Pair, + newRefsFormat: Boolean = false): GitLogParserTest.GitTestLogRecord { val data = mutableMapOf(Pair(GitLogParserTest.GitTestLogRecordInfo.AUTHOR_TIME, Date(1317027817L * 1000)), Pair(GitLogParserTest.GitTestLogRecordInfo.AUTHOR_NAME, "John Doe"), Pair(GitLogParserTest.GitTestLogRecordInfo.AUTHOR_EMAIL, "John.Doe@example.com"), @@ -436,7 +433,7 @@ private fun createTestRecord(vararg parameters: Pair { +internal fun generateRecords(newRefsFormat: Boolean): MutableList { val records = mutableListOf() records.add(createTestRecord(Pair(GitLogParserTest.GitTestLogRecordInfo.COMMIT_NAME, "Bob Smith"), Pair(GitLogParserTest.GitTestLogRecordInfo.COMMIT_EMAIL, "Bob@site.com"), @@ -465,13 +462,15 @@ internal fun generateRecords(): MutableList { GitLogParserTest.GitTestChange.modified("src/CClass.java"), GitLogParserTest.GitTestChange.deleted("src/ChildAClass.java"))), Pair(GitLogParserTest.GitTestLogRecordInfo.REFS, - Arrays.asList("HEAD", "refs/heads/master")))) + Arrays.asList("HEAD", "refs/heads/master")), + newRefsFormat = newRefsFormat)) records.add(createTestRecord(Pair(GitLogParserTest.GitTestLogRecordInfo.SUBJECT, "Commit message"), Pair(GitLogParserTest.GitTestLogRecordInfo.BODY, "Small description"), Pair(GitLogParserTest.GitTestLogRecordInfo.PARENTS, arrayOf(records[0].hash)), Pair(GitLogParserTest.GitTestLogRecordInfo.CHANGES, - arrayOf(GitLogParserTest.GitTestChange.modified("src/CClass.java"))))) + arrayOf(GitLogParserTest.GitTestChange.modified("src/CClass.java"))), + newRefsFormat = newRefsFormat)) records.add(createTestRecord(Pair(GitLogParserTest.GitTestLogRecordInfo.SUBJECT, "Commit message"), Pair(GitLogParserTest.GitTestLogRecordInfo.BODY, "Small description"), @@ -481,7 +480,8 @@ internal fun generateRecords(): MutableList { arrayOf(GitLogParserTest.GitTestChange.modified("src/CClass.java"))), Pair(GitLogParserTest.GitTestLogRecordInfo.REFS, Arrays.asList("refs/heads/sly->name", "refs/remotes/origin/master", - "refs/tags/v1.0")))) + "refs/tags/v1.0")), + newRefsFormat = newRefsFormat)) return records } \ No newline at end of file