Skip to content

Commit d2b4526

Browse files
feat: add unit test for URL version replacement logic
1 parent c7b5e22 commit d2b4526

File tree

1 file changed

+14
-0
lines changed
  • pulsar-common/src/test/kotlin/ai/platon/pulsar/common

1 file changed

+14
-0
lines changed

pulsar-common/src/test/kotlin/ai/platon/pulsar/common/TestString.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ class TestString {
122122
}
123123
}
124124

125+
@Test
126+
fun testReplaceInURL() {
127+
val url = "https://github.com/platonai/PulsarRPA/releases/download/v3.0.14/PulsarRPA.jar"
128+
val expectedURL = "https://github.com/platonai/PulsarRPA/releases/download/v3.0.15/PulsarRPA.jar"
129+
val regex = "https?:.+(v\\d+\\.\\d+\\.\\d+).+".toRegex()
130+
val replacement = "v3.0.15"
131+
132+
val newURL = regex.replace(url) { matchResult ->
133+
url.replace(matchResult.groupValues[1], replacement)
134+
}
135+
136+
assertEquals(expectedURL, newURL)
137+
}
138+
125139
@Test
126140
fun testAvailableCharsets() {
127141
var charsets = Charset.availableCharsets().values.stream()

0 commit comments

Comments
 (0)