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
8a4fb43a
Commit
8a4fb43a
authored
3 years ago
by
Sebastian
Browse files
Options
Downloads
Patches
Plain Diff
Add test that creates database on Android
parent
0ead2a80
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7355
failed
3 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mailbox-android/build.gradle
+3
-0
3 additions, 0 deletions
mailbox-android/build.gradle
mailbox-android/src/androidTest/java/org/briarproject/mailbox/core/DatabaseCreationTest.kt
+50
-0
50 additions, 0 deletions
...ava/org/briarproject/mailbox/core/DatabaseCreationTest.kt
with
53 additions
and
0 deletions
mailbox-android/build.gradle
+
3
−
0
View file @
8a4fb43a
...
...
@@ -78,8 +78,11 @@ dependencies {
testImplementation
'junit:junit:4.13.2'
androidTestImplementation
"org.jetbrains.kotlin:kotlin-test:$kotlin_version"
androidTestImplementation
'androidx.test.ext:junit:1.1.3'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation
'androidx.test:runner:1.1.0'
androidTestImplementation
'androidx.test:rules:1.1.0'
}
def
torBinariesDir
=
'src/main/res/raw'
...
...
This diff is collapsed.
Click to expand it.
mailbox-android/src/androidTest/java/org/briarproject/mailbox/core/DatabaseCreationTest.kt
0 → 100644
+
50
−
0
View file @
8a4fb43a
package
org.briarproject.mailbox.core
import
kotlinx.coroutines.runBlocking
import
org.junit.Test
import
org.sqlite.mc.SQLiteMCConfig
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"
,
SQLiteMCConfig
().
withKey
(
"very-secret"
).
toProperties
())
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
)
}
}
\ No newline at end of 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