Skip to content

Commit f3dbc1c

Browse files
committed
Extract Endpoint class to a separate module for reuse
1 parent a7e3375 commit f3dbc1c

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ enableFeaturePreview("VERSION_CATALOGS")
33
rootProject.name = "jprof_by_bot"
44

55
include(":utils:dynamodb")
6+
include(":utils:aws-junit5")
67
include(":votes")
78
include(":votes:dynamodb")
89
include(":votes:tgbotapi-extensions")

utils/aws-junit5/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
kotlin("jvm")
3+
}
4+
5+
dependencies {
6+
api(libs.aws.junit5.dynamo.v2)
7+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package by.jprof.telegram.bot.utils.aws_junit5
2+
3+
import me.madhead.aws_junit5.common.AWSEndpoint
4+
5+
class Endpoint : AWSEndpoint {
6+
override fun url(): String {
7+
return System.getenv("DYNAMODB_URL")
8+
}
9+
10+
override fun region(): String {
11+
return System.getenv("AWS_DEFAULT_REGION")
12+
}
13+
14+
override fun accessKey(): String {
15+
return System.getenv("AWS_ACCESS_KEY_ID")
16+
}
17+
18+
override fun secretKey(): String {
19+
return System.getenv("AWS_SECRET_ACCESS_KEY")
20+
}
21+
}

votes/dynamodb/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies {
1111
testImplementation(libs.junit.jupiter.api)
1212
testImplementation(libs.junit.jupiter.params)
1313
testImplementation(libs.aws.junit5.dynamo.v2)
14+
testImplementation(project.projects.utils.awsJunit5)
1415
testRuntimeOnly(libs.junit.jupiter.engine)
1516
}
1617

votes/dynamodb/src/test/kotlin/by/jprof/telegram/bot/votes/dynamodb/dao/VotesDAOTest.kt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package by.jprof.telegram.bot.votes.dynamodb.dao
22

3+
import by.jprof.telegram.bot.utils.aws_junit5.Endpoint
34
import by.jprof.telegram.bot.votes.model.Votes
45
import kotlinx.coroutines.runBlocking
56
import me.madhead.aws_junit5.common.AWSClient
6-
import me.madhead.aws_junit5.common.AWSEndpoint
77
import me.madhead.aws_junit5.dynamo.v2.DynamoDB
88
import org.junit.jupiter.api.*
99
import org.junit.jupiter.api.extension.ExtendWith
@@ -46,22 +46,4 @@ internal class VotesDAOTest {
4646
"User2" to "-",
4747
)
4848
)
49-
50-
class Endpoint : AWSEndpoint {
51-
override fun url(): String {
52-
return System.getenv("DYNAMODB_URL")
53-
}
54-
55-
override fun region(): String {
56-
return System.getenv("AWS_DEFAULT_REGION")
57-
}
58-
59-
override fun accessKey(): String {
60-
return System.getenv("AWS_ACCESS_KEY_ID")
61-
}
62-
63-
override fun secretKey(): String {
64-
return System.getenv("AWS_SECRET_ACCESS_KEY")
65-
}
66-
}
6749
}

0 commit comments

Comments
 (0)