Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar Desktop
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
Model registry
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 Desktop
Commits
0eec35bb
Commit
0eec35bb
authored
3 years ago
by
Sebastian
Committed by
Mikolai Gütschow
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a testing executable that uses a temporary data directory
parent
3aedf3e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Make it possible to start briar with temporary account with a bunch of testing contacts
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/kotlin/org/briarproject/briar/desktop/TestWithTemporaryAccount.kt
+66
-0
66 additions, 0 deletions
...rg/briarproject/briar/desktop/TestWithTemporaryAccount.kt
with
66 additions
and
0 deletions
src/test/kotlin/org/briarproject/briar/desktop/TestWithTemporaryAccount.kt
0 → 100644
+
66
−
0
View file @
0eec35bb
package
org.briarproject.briar.desktop
import
androidx.compose.ui.ExperimentalComposeUiApi
import
androidx.compose.ui.window.application
import
org.briarproject.bramble.BrambleCoreEagerSingletons
import
org.briarproject.bramble.util.OsUtils.isLinux
import
org.briarproject.bramble.util.OsUtils.isMac
import
org.briarproject.bramble.util.OsUtils.isWindows
import
org.briarproject.briar.BriarCoreEagerSingletons
import
java.io.IOException
import
java.nio.file.Files
import
java.nio.file.Files.setPosixFilePermissions
import
java.nio.file.Path
import
java.nio.file.attribute.PosixFilePermission
import
java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE
import
java.nio.file.attribute.PosixFilePermission.OWNER_READ
import
java.nio.file.attribute.PosixFilePermission.OWNER_WRITE
import
java.util.logging.Level.INFO
import
java.util.logging.LogManager
import
kotlin.io.path.absolute
private
class
TestWithTemporaryAccount
{
@OptIn
(
ExperimentalComposeUiApi
::
class
)
fun
run
()
=
application
{
LogManager
.
getLogManager
().
getLogger
(
""
).
level
=
INFO
val
dataDir
=
getDataDir
()
println
(
"Using data directory '$dataDir'"
)
val
app
=
DaggerBriarDesktopApp
.
builder
().
desktopModule
(
DesktopModule
(
dataDir
.
toFile
())
).
build
()
// We need to load the eager singletons directly after making the
// dependency graphs
BrambleCoreEagerSingletons
.
Helper
.
injectEagerSingletons
(
app
)
BriarCoreEagerSingletons
.
Helper
.
injectEagerSingletons
(
app
)
app
.
getUI
().
startBriar
()
}
private
fun
getDataDir
():
Path
{
val
dataDir
=
Files
.
createTempDirectory
(
"briar"
)
if
(!
Files
.
exists
(
dataDir
))
{
throw
IOException
(
"Could not create directory: ${dataDir.absolute()}"
)
}
else
if
(!
Files
.
isDirectory
(
dataDir
))
{
throw
IOException
(
"Data dir is not a directory: ${dataDir.absolute()}"
)
}
if
(
isLinux
()
||
isMac
())
{
val
perms
=
HashSet
<
PosixFilePermission
>()
perms
.
add
(
OWNER_READ
)
perms
.
add
(
OWNER_WRITE
)
perms
.
add
(
OWNER_EXECUTE
)
setPosixFilePermissions
(
dataDir
,
perms
)
}
else
if
(
isWindows
())
{
val
file
=
dataDir
.
toFile
()
file
.
setReadable
(
true
,
true
)
file
.
setWritable
(
true
,
true
)
file
.
setExecutable
(
true
,
true
)
}
return
dataDir
}
}
fun
main
(
args
:
Array
<
String
>)
=
TestWithTemporaryAccount
().
run
()
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