File tree Expand file tree Collapse file tree 4 files changed +19
-8
lines changed
main/kotlin/com/github/yusufugurozbek/testcontainers/port/updater
test/kotlin/com/github/yusufugurozbek/testcontainers/port/updater Expand file tree Collapse file tree 4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1
1
# Testcontainers Port Updater Changelog
2
2
3
3
## [ Unreleased]
4
+ - Improve regex pattern
4
5
5
6
## [ 0.1.1]
6
7
- Support latest IntelliJ 2022.1
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package com.github.yusufugurozbek.testcontainers.port.updater
2
2
3
3
class DatasourceUrlExtractor {
4
4
5
- private val regex: Regex = " Database: (.*?) \\ ((.*?) \\ )" .toRegex()
5
+ private val regex: Regex = " Database: (.*?)(?! \\ S )" .toRegex()
6
6
7
7
internal fun extract (from : String ): String? {
8
8
val find = regex.find(from)
Original file line number Diff line number Diff line change 1
1
package com.github.yusufugurozbek.testcontainers.port.updater
2
2
3
- import com.github.yusufugurozbek.testcontainers.port.updater.TestConstants.DATASOURCE_URL
4
- import com.github.yusufugurozbek.testcontainers.port.updater.TestConstants.LOG_ENTRY
3
+ import com.github.yusufugurozbek.testcontainers.port.updater.TestConstants.DATASOURCE_URL_1
4
+ import com.github.yusufugurozbek.testcontainers.port.updater.TestConstants.DATASOURCE_URL_2
5
+ import com.github.yusufugurozbek.testcontainers.port.updater.TestConstants.LOG_ENTRY_1
6
+ import com.github.yusufugurozbek.testcontainers.port.updater.TestConstants.LOG_ENTRY_2
5
7
import org.junit.jupiter.api.Assertions.assertEquals
6
8
import org.junit.jupiter.api.Test
7
9
@@ -10,8 +12,13 @@ internal class DatasourceUrlExtractorTest {
10
12
private val sut = DatasourceUrlExtractor ()
11
13
12
14
@Test
13
- fun `extractDataSourceUrl successfully extracts url if present` () {
14
- assertEquals(sut.extract(LOG_ENTRY ), DATASOURCE_URL )
15
+ fun `extractDataSourceUrl successfully extracts url if present with driver part` () {
16
+ assertEquals(sut.extract(LOG_ENTRY_1 ), DATASOURCE_URL_1 )
17
+ }
18
+
19
+ @Test
20
+ fun `extractDataSourceUrl successfully extracts url if present without driver part` () {
21
+ assertEquals(sut.extract(LOG_ENTRY_2 ), DATASOURCE_URL_2 )
15
22
}
16
23
17
24
@Test
Original file line number Diff line number Diff line change 1
1
package com.github.yusufugurozbek.testcontainers.port.updater
2
2
3
3
object TestConstants {
4
- const val DATASOURCE_URL = " jdbc:postgresql://localhost:55001/test"
5
- const val LOG_ENTRY =
6
- " 2021-07-16 14:05:56.360 INFO [my-application,,] 33702 --- [" +
4
+ const val DATASOURCE_URL_1 = " jdbc:postgresql://localhost:55001/test"
5
+ const val DATASOURCE_URL_2 = " jdbc:postgresql://localhost:55001/test?loggerLevel=OFF "
6
+ const val LOG_ENTRY_1 = " 2021-07-16 14:05:56.360 INFO [my-application,,] 33702 --- [" +
7
7
" main] o.f.c.i.database.base.DatabaseType : " +
8
8
" Database: jdbc:postgresql://localhost:55001/test (PostgreSQL 10.17)"
9
+ const val LOG_ENTRY_2 = " 2021-07-16 14:05:56.360 INFO [my-application,,] 33702 --- [" +
10
+ " main] o.f.c.i.database.base.DatabaseType : " +
11
+ " Database: jdbc:postgresql://localhost:55001/test?loggerLevel=OFF"
9
12
}
You can’t perform that action at this time.
0 commit comments