Skip to content

Commit ea462a0

Browse files
authored
(DOCSP-29415): Update GH action to run local mongoDB server (#85)
# Pull Request Info [PR Reviewing Guidelines](https://github.com/mongodb/docs-java/blob/master/REVIEWING.md) Updates the GH action to run a local server. Any pending PRs will need to be updated to use `getConfig()` or the test will fail. > NOTE: Currently, it creates a replica set with no users. JIRA - https://jira.mongodb.org/browse/DOCSP-29415 Staging - https://docs-mongodbcom-staging.corp.mongodb.com/kotlin/docsworker-xlarge/no-jira-logging-import-fix/ ## Self-Review Checklist - [ ] Is this free of any warnings or errors in the RST? - [ ] Did you run a spell-check? - [ ] Did you run a grammar-check? - [ ] Are all the links working?
1 parent 86b65bf commit ea462a0

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

.github/workflows/kotlin.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ defaults:
1212
jobs:
1313
build:
1414
name: Run Kotlin Example Tests
15-
runs-on: macos-latest
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
mongodb-version: ['6.0']
1619

1720
steps:
1821
- uses: actions/checkout@v3
@@ -21,8 +24,18 @@ jobs:
2124
with:
2225
distribution: 'zulu'
2326
java-version: 11
24-
- name: Run Kotlin tests
27+
28+
- name: Start MongoDB
29+
uses: supercharge/[email protected]
30+
with:
31+
mongodb-version: ${{ matrix.mongodb-version }}
32+
mongodb-replica-set: test-rs
33+
34+
- name: Validate Gradle Wrapper
35+
uses: gradle/wrapper-validation-action@v1
36+
37+
- name: Run Tests
2538
run: ./gradlew test --stacktrace --info
2639
env:
2740
CI: true
28-
CONNECTION_URI: ${{ secrets.CONNECTION_URI }}
41+
CONNECTION_URI: "mongodb://localhost:27017"

examples/src/test/kotlin/BuildersTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ internal class BuildersTest {
5656
client.close()
5757
}
5858
}
59-
6059
}
6160

6261
@Test

examples/src/test/kotlin/ChangeTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ internal class ChangeTest {
5353
}
5454
}
5555
}
56+
5657
@Test
5758
fun updateOneTest() = runBlocking {
5859
// :snippet-start: update-one

examples/src/test/kotlin/ConnectTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal class ConnectionTest {
6363
}
6464
// :snippet-end:
6565
higherScopedClient = mongoClient
66-
assertEquals(1, higherScopedCommandResult["ok"])
66+
assertEquals(1.0, higherScopedCommandResult["ok"].toString().toDouble())
6767
}
6868

6969
@Test

examples/src/test/kotlin/LimitTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import org.junit.jupiter.api.BeforeAll
1111
import org.junit.jupiter.api.TestInstance
1212
import kotlin.test.*
1313

14-
// :snippet-start: data-model
15-
data class Book(
16-
@BsonId val id: Int,
17-
val title: String,
18-
val author: String,
19-
val length: Int
20-
)
21-
// :snippet-end:
22-
2314
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
2415
internal class LimitTest {
2516

17+
// :snippet-start: data-model
18+
data class Book(
19+
@BsonId val id: Int,
20+
val title: String,
21+
val author: String,
22+
val length: Int
23+
)
24+
// :snippet-end:
25+
2626
companion object {
2727
val config = getConfig()
2828
val client = MongoClient.create(config.connectionUri)

examples/src/test/kotlin/LoggingTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
3-
// :snippet-start: slf4j-import
4-
// :snippet-end:
51
import InsertTest.Companion.client
62
import com.mongodb.kotlin.client.coroutine.MongoClient
73
import config.getConfig
@@ -11,7 +7,9 @@ import org.bson.Document
117
import org.junit.jupiter.api.AfterAll
128
import org.junit.jupiter.api.Assertions.*
139
import org.junit.jupiter.api.TestInstance
10+
// :snippet-start: slf4j-import
1411
import org.slf4j.LoggerFactory
12+
// :snippet-end:
1513
import java.util.*
1614
import kotlin.test.*
1715

0 commit comments

Comments
 (0)