Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar Mailbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar Mailbox
Commits
f21c6811
Commit
f21c6811
authored
3 years ago
by
Sebastian
Browse files
Options
Downloads
Patches
Plain Diff
Add an initial test for io.github.willena:sqlite-jdbc
parent
7682f0dc
No related branches found
No related tags found
No related merge requests found
Pipeline
#7338
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mailbox-core/build.gradle
+1
-0
1 addition, 0 deletions
mailbox-core/build.gradle
mailbox-core/src/test/java/org/briarproject/mailbox/core/db/DatabaseCreationTest.kt
+48
-0
48 additions, 0 deletions
.../org/briarproject/mailbox/core/db/DatabaseCreationTest.kt
with
49 additions
and
0 deletions
mailbox-core/build.gradle
+
1
−
0
View file @
f21c6811
...
...
@@ -13,6 +13,7 @@ dependencies {
api
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api
'com.google.code.findbugs:jsr305:3.0.2'
api
'javax.inject:javax.inject:1'
// required for @Qualifier in @Wakeful
api
'io.github.willena:sqlite-jdbc:3.35.5.3'
implementation
"com.google.dagger:hilt-core:$hilt_version"
kapt
"com.google.dagger:dagger-compiler:$hilt_version"
...
...
This diff is collapsed.
Click to expand it.
mailbox-core/src/test/java/org/briarproject/mailbox/core/db/DatabaseCreationTest.kt
0 → 100644
+
48
−
0
View file @
f21c6811
package
org.briarproject.mailbox.core.db
import
kotlinx.coroutines.runBlocking
import
org.junit.jupiter.api.Test
import
java.nio.file.Files
import
java.nio.file.Path
import
java.sql.Connection
import
java.sql.DriverManager
import
kotlin.test.assertEquals
import
kotlin.test.assertTrue
class
DatabaseCreationTest
{
@Test
fun
createDatabase
():
Unit
=
runBlocking
{
val
file
:
Path
=
Files
.
createTempFile
(
"test"
,
".sqlite"
)
println
(
file
)
val
connection
:
Connection
=
DriverManager
.
getConnection
(
"jdbc:sqlite:$file"
)
val
stmt
=
connection
.
createStatement
()
stmt
.
executeUpdate
(
"CREATE TABLE students (id integer, name string)"
)
stmt
.
executeUpdate
(
"INSERT INTO students values (1, 'alice')"
)
stmt
.
executeUpdate
(
"INSERT INTO students values (2, 'bob')"
)
val
prep
=
connection
.
prepareStatement
(
"SELECT * FROM students"
)
val
results
=
prep
.
executeQuery
()
for
(
i
in
0
..
1
)
{
val
available
=
results
.
next
()
assertTrue
(
available
)
val
id
=
results
.
getInt
(
1
)
val
name
=
results
.
getString
(
2
)
when
(
i
)
{
0
->
{
assertEquals
(
1
,
id
)
assertEquals
(
"alice"
,
name
)
}
1
->
{
assertEquals
(
2
,
id
)
assertEquals
(
"bob"
,
name
)
}
}
}
Files
.
delete
(
file
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment