Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Fixing broken issue url. (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorobtsov authored Apr 8, 2020
1 parent 63de7d8 commit 03df03c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ fun createTmsLink(value: String): Link {
}

fun createLink(value: String?, name: String?, url: String?, type: String): Link {
return Link(name = value ?: name, url = url ?: getLinkUrl(name, type), type = type)
val linkName = value ?: name
val linkUrl = url ?: getLinkUrl(linkName, type)
return Link(linkName, linkUrl, type)
}

fun getLinkUrl(name: String?, type: String): String? {
val pattern = System.getProperty("allure.link.$type.pattern") ?: return null
return pattern.replace("\\{}", name ?: "")
return pattern.replace("{}", name ?: "")
}

fun createLabels(epics: Epics): List<Label> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.qameta.allure.android.utils

import org.junit.Test

import org.junit.Assert.*

class ResultsUtilsCommonKtTest {

@Test
fun `createIssueLink should return valid url`() {
val id = "ISSUE-11"
val pattern = "https://www.issue.tracker.com/{}"
System.setProperty("allure.link.issue.pattern", pattern)

val link = createIssueLink(id)
val expectedUrl = pattern.replace("{}", id)

assertEquals(expectedUrl, link.url)
}

@Test
fun `createTmsLink should return valid url`() {
val id = "TMS-11"
val pattern = "https://www.issue.tracker.com/{}"
System.setProperty("allure.link.tms.pattern", pattern)

val link = createTmsLink(id)
val expectedUrl = pattern.replace("{}", id)

assertEquals(expectedUrl, link.url)
}

}

0 comments on commit 03df03c

Please sign in to comment.