diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/server/AbstractSyncServer.kt b/uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/AbstractSyncServer.kt
similarity index 90%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/server/AbstractSyncServer.kt
rename to uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/AbstractSyncServer.kt
index f3afe7bf0..713c81a5e 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/server/AbstractSyncServer.kt
+++ b/uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/AbstractSyncServer.kt
@@ -17,12 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.server
-
-import org.isoron.uhabits.sync.EditConflictException
-import org.isoron.uhabits.sync.KeyNotFoundException
-import org.isoron.uhabits.sync.ServiceUnavailable
-import org.isoron.uhabits.sync.SyncData
+package org.isoron.uhabits.core.sync
interface AbstractSyncServer {
/**
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/SyncData.kt b/uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/SyncData.kt
similarity index 77%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/SyncData.kt
rename to uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/SyncData.kt
index 65fcd1ae9..3910ce775 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/SyncData.kt
+++ b/uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/SyncData.kt
@@ -17,9 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync
-
-import com.fasterxml.jackson.databind.ObjectMapper
+package org.isoron.uhabits.core.sync
data class SyncData(
val version: Long,
@@ -29,7 +27,3 @@ data class SyncData(
data class RegisterReponse(val key: String)
data class GetDataVersionResponse(val version: Long)
-
-val defaultMapper = ObjectMapper()
-fun SyncData.toJson(): String = defaultMapper.writeValueAsString(this)
-fun GetDataVersionResponse.toJson(): String = defaultMapper.writeValueAsString(this)
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/SyncException.kt b/uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/SyncException.kt
similarity index 96%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/SyncException.kt
rename to uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/SyncException.kt
index 7a8d615f3..407880566 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/SyncException.kt
+++ b/uhabits-core/src/commonMain/kotlin/org/isoron/uhabits/core/sync/SyncException.kt
@@ -17,7 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync
+package org.isoron.uhabits.core.sync
open class SyncException : RuntimeException()
diff --git a/uhabits-server/build.gradle.kts b/uhabits-server/build.gradle.kts
index bfe94836a..dc56f8b46 100644
--- a/uhabits-server/build.gradle.kts
+++ b/uhabits-server/build.gradle.kts
@@ -36,6 +36,7 @@ dependencies {
val ktorVersion = "1.6.6"
val kotlinVersion = "1.6.0"
val logbackVersion = "1.2.7"
+ implementation(project(":uhabits-core"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("io.ktor:ktor-server-netty:$ktorVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/MetricsModule.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/MetricsModule.kt
similarity index 97%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/MetricsModule.kt
rename to uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/MetricsModule.kt
index 379f96ad8..a05403348 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/MetricsModule.kt
+++ b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/MetricsModule.kt
@@ -17,7 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.app
+package org.isoron.uhabits.server.app
import io.ktor.application.call
import io.ktor.http.HttpStatusCode
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/RegistrationModule.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/RegistrationModule.kt
similarity index 89%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/RegistrationModule.kt
rename to uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/RegistrationModule.kt
index 2f9d3ef54..ae7b196f9 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/RegistrationModule.kt
+++ b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/RegistrationModule.kt
@@ -17,15 +17,15 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.app
+package org.isoron.uhabits.server.app
import io.ktor.application.call
import io.ktor.http.HttpStatusCode
import io.ktor.response.respond
import io.ktor.routing.Routing
import io.ktor.routing.post
-import org.isoron.uhabits.sync.RegisterReponse
-import org.isoron.uhabits.sync.ServiceUnavailable
+import org.isoron.uhabits.core.sync.RegisterReponse
+import org.isoron.uhabits.core.sync.ServiceUnavailable
fun Routing.registration(app: SyncApplication) {
post("/register") {
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/StorageModule.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/StorageModule.kt
similarity index 89%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/StorageModule.kt
rename to uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/StorageModule.kt
index aa2689513..cd337f15d 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/StorageModule.kt
+++ b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/StorageModule.kt
@@ -17,7 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.app
+package org.isoron.uhabits.server.app
import io.ktor.application.call
import io.ktor.http.HttpStatusCode
@@ -27,10 +27,10 @@ import io.ktor.routing.Routing
import io.ktor.routing.get
import io.ktor.routing.put
import io.ktor.routing.route
-import org.isoron.uhabits.sync.EditConflictException
-import org.isoron.uhabits.sync.GetDataVersionResponse
-import org.isoron.uhabits.sync.KeyNotFoundException
-import org.isoron.uhabits.sync.SyncData
+import org.isoron.uhabits.core.sync.EditConflictException
+import org.isoron.uhabits.core.sync.GetDataVersionResponse
+import org.isoron.uhabits.core.sync.KeyNotFoundException
+import org.isoron.uhabits.core.sync.SyncData
fun Routing.storage(app: SyncApplication) {
route("/db/{key}") {
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/SyncApplication.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/SyncApplication.kt
similarity index 86%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/SyncApplication.kt
rename to uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/SyncApplication.kt
index 2e49f15e5..dd7cf1856 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/app/SyncApplication.kt
+++ b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/app/SyncApplication.kt
@@ -17,7 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.app
+package org.isoron.uhabits.server.app
import io.ktor.application.Application
import io.ktor.application.install
@@ -26,9 +26,9 @@ import io.ktor.features.ContentNegotiation
import io.ktor.features.DefaultHeaders
import io.ktor.jackson.jackson
import io.ktor.routing.routing
-import org.isoron.uhabits.sync.repository.FileRepository
-import org.isoron.uhabits.sync.server.AbstractSyncServer
-import org.isoron.uhabits.sync.server.RepositorySyncServer
+import org.isoron.uhabits.server.sync.Repository
+import org.isoron.uhabits.core.sync.AbstractSyncServer
+import org.isoron.uhabits.server.sync.RepositorySyncServer
import java.nio.file.Path
import java.nio.file.Paths
@@ -38,7 +38,7 @@ val REPOSITORY_PATH: Path = Paths.get(System.getenv("LOOP_REPO_PATH")!!)
class SyncApplication(
val server: AbstractSyncServer = RepositorySyncServer(
- FileRepository(REPOSITORY_PATH),
+ Repository(REPOSITORY_PATH),
),
) {
fun Application.main() {
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/repository/FileRepository.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/Repository.kt
similarity index 86%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/repository/FileRepository.kt
rename to uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/Repository.kt
index 72ec57c5b..dd5aac506 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/repository/FileRepository.kt
+++ b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/Repository.kt
@@ -17,18 +17,17 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.repository
+package org.isoron.uhabits.server.sync
-import org.isoron.uhabits.sync.KeyNotFoundException
-import org.isoron.uhabits.sync.SyncData
+import org.isoron.uhabits.core.sync.KeyNotFoundException
+import org.isoron.uhabits.core.sync.SyncData
import java.io.PrintWriter
import java.nio.file.Path
-class FileRepository(
+class Repository(
private val basepath: Path,
-) : Repository {
-
- override suspend fun put(key: String, data: SyncData) {
+) {
+ fun put(key: String, data: SyncData) {
// Create directory
val dataPath = key.toDataPath()
val dataDir = dataPath.toFile()
@@ -51,7 +50,7 @@ class FileRepository(
}
}
- override suspend fun get(key: String): SyncData {
+ fun get(key: String): SyncData {
val dataPath = key.toDataPath()
val contentFile = dataPath.resolve("content").toFile()
val versionFile = dataPath.resolve("version").toFile()
@@ -62,7 +61,7 @@ class FileRepository(
return SyncData(version, contentFile.readText())
}
- override suspend fun contains(key: String): Boolean {
+ fun contains(key: String): Boolean {
val dataPath = key.toDataPath()
val versionFile = dataPath.resolve("version").toFile()
return versionFile.exists()
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/server/RepositorySyncServer.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/RepositorySyncServer.kt
similarity index 78%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/server/RepositorySyncServer.kt
rename to uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/RepositorySyncServer.kt
index 30f9abbe2..2372725c8 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/server/RepositorySyncServer.kt
+++ b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/RepositorySyncServer.kt
@@ -17,14 +17,15 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.server
+package org.isoron.uhabits.server.sync
import io.prometheus.client.Counter
-import org.isoron.uhabits.sync.EditConflictException
-import org.isoron.uhabits.sync.KeyNotFoundException
-import org.isoron.uhabits.sync.SyncData
-import org.isoron.uhabits.sync.repository.Repository
-import org.isoron.uhabits.sync.utils.randomString
+import org.isoron.uhabits.core.sync.AbstractSyncServer
+import org.isoron.uhabits.core.sync.EditConflictException
+import org.isoron.uhabits.core.sync.KeyNotFoundException
+import org.isoron.uhabits.core.sync.SyncData
+import java.util.Random
+import kotlin.streams.asSequence
/**
* An AbstractSyncServer that stores all data in a [Repository].
@@ -74,11 +75,19 @@ class RepositorySyncServer(
return repo.get(key).version
}
- private suspend fun generateKey(): String {
+ private fun generateKey(): String {
while (true) {
val key = randomString(64)
if (!repo.contains(key))
return key
}
}
+
+ private fun randomString(length: Long): String {
+ val chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ return Random().ints(length, 0, chars.length)
+ .asSequence()
+ .map(chars::get)
+ .joinToString("")
+ }
}
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/utils/String.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/SyncDataExt.kt
similarity index 67%
rename from uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/utils/String.kt
rename to uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/SyncDataExt.kt
index 6427b326b..f389e6bfe 100644
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/utils/String.kt
+++ b/uhabits-server/src/main/kotlin/org/isoron/uhabits/server/sync/SyncDataExt.kt
@@ -17,15 +17,12 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.utils
+package org.isoron.uhabits.server.sync
-import java.util.Random
-import kotlin.streams.asSequence
+import com.fasterxml.jackson.databind.ObjectMapper
+import org.isoron.uhabits.core.sync.GetDataVersionResponse
+import org.isoron.uhabits.core.sync.SyncData
-fun randomString(length: Long): String {
- val chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- return Random().ints(length, 0, chars.length)
- .asSequence()
- .map(chars::get)
- .joinToString("")
-}
+val defaultMapper = ObjectMapper()
+fun SyncData.toJson(): String = defaultMapper.writeValueAsString(this)
+fun GetDataVersionResponse.toJson(): String = defaultMapper.writeValueAsString(this)
diff --git a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/repository/Repository.kt b/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/repository/Repository.kt
deleted file mode 100644
index 1e9817ad3..000000000
--- a/uhabits-server/src/main/kotlin/org/isoron/uhabits/sync/repository/Repository.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2016-2021 Álinson Santos Xavier
- *
- * This file is part of Loop Habit Tracker.
- *
- * Loop Habit Tracker is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version.
- *
- * Loop Habit Tracker is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-package org.isoron.uhabits.sync.repository
-
-import org.isoron.uhabits.sync.KeyNotFoundException
-import org.isoron.uhabits.sync.SyncData
-
-/**
- * A class that knows how to store and retrieve a large number of [SyncData] items.
- */
-interface Repository {
- /**
- * Stores a data item, under the provided key. The item can be later retrieved with [get].
- * Replaces existing items silently.
- */
- suspend fun put(key: String, data: SyncData)
-
- /**
- * Retrieves a data item that was previously stored using [put].
- * @throws KeyNotFoundException If no such key exists.
- */
- suspend fun get(key: String): SyncData
-
- /**
- * Returns true if the repository contains a given key.
- */
- suspend fun contains(key: String): Boolean
-}
diff --git a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/BaseApplicationTest.kt b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/BaseApplicationTest.kt
similarity index 92%
rename from uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/BaseApplicationTest.kt
rename to uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/BaseApplicationTest.kt
index 07111720d..1ac6dfd78 100644
--- a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/BaseApplicationTest.kt
+++ b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/BaseApplicationTest.kt
@@ -17,11 +17,11 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.app
+package org.isoron.uhabits.server.app
import com.nhaarman.mockitokotlin2.mock
import io.ktor.application.Application
-import org.isoron.uhabits.sync.server.AbstractSyncServer
+import org.isoron.uhabits.core.sync.AbstractSyncServer
open class BaseApplicationTest {
diff --git a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/RegistrationModuleTest.kt b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/RegistrationModuleTest.kt
similarity index 95%
rename from uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/RegistrationModuleTest.kt
rename to uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/RegistrationModuleTest.kt
index 8fa80883a..4f2ab516f 100644
--- a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/RegistrationModuleTest.kt
+++ b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/RegistrationModuleTest.kt
@@ -17,7 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.app
+package org.isoron.uhabits.server.app
import com.nhaarman.mockitokotlin2.whenever
import io.ktor.http.HttpMethod
@@ -25,7 +25,7 @@ import io.ktor.http.HttpStatusCode
import io.ktor.server.testing.handleRequest
import io.ktor.server.testing.withTestApplication
import kotlinx.coroutines.runBlocking
-import org.isoron.uhabits.sync.ServiceUnavailable
+import org.isoron.uhabits.core.sync.ServiceUnavailable
import org.junit.Test
import kotlin.test.assertEquals
diff --git a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/StorageModuleTest.kt b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/StorageModuleTest.kt
similarity index 93%
rename from uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/StorageModuleTest.kt
rename to uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/StorageModuleTest.kt
index 5d6d69321..71576fb86 100644
--- a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/app/StorageModuleTest.kt
+++ b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/app/StorageModuleTest.kt
@@ -17,7 +17,7 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.app
+package org.isoron.uhabits.server.app
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
@@ -31,11 +31,11 @@ import io.ktor.server.testing.handleRequest
import io.ktor.server.testing.setBody
import io.ktor.server.testing.withTestApplication
import kotlinx.coroutines.runBlocking
-import org.isoron.uhabits.sync.EditConflictException
-import org.isoron.uhabits.sync.GetDataVersionResponse
-import org.isoron.uhabits.sync.KeyNotFoundException
-import org.isoron.uhabits.sync.SyncData
-import org.isoron.uhabits.sync.toJson
+import org.isoron.uhabits.core.sync.EditConflictException
+import org.isoron.uhabits.core.sync.GetDataVersionResponse
+import org.isoron.uhabits.core.sync.KeyNotFoundException
+import org.isoron.uhabits.core.sync.SyncData
+import org.isoron.uhabits.server.sync.toJson
import org.junit.Test
import kotlin.test.assertEquals
diff --git a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/server/RepositorySyncServerTest.kt b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/sync/RepositorySyncServerTest.kt
similarity index 85%
rename from uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/server/RepositorySyncServerTest.kt
rename to uhabits-server/src/test/kotlin/org/isoron/uhabits/server/sync/RepositorySyncServerTest.kt
index cbe71e027..a6854d677 100644
--- a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/server/RepositorySyncServerTest.kt
+++ b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/sync/RepositorySyncServerTest.kt
@@ -17,13 +17,12 @@
* with this program. If not, see .
*/
-package org.isoron.uhabits.sync.server
+package org.isoron.uhabits.server.sync
import kotlinx.coroutines.runBlocking
-import org.isoron.uhabits.sync.EditConflictException
-import org.isoron.uhabits.sync.KeyNotFoundException
-import org.isoron.uhabits.sync.SyncData
-import org.isoron.uhabits.sync.repository.FileRepository
+import org.isoron.uhabits.core.sync.EditConflictException
+import org.isoron.uhabits.core.sync.KeyNotFoundException
+import org.isoron.uhabits.core.sync.SyncData
import org.junit.Test
import java.nio.file.Files
import kotlin.test.assertEquals
@@ -32,7 +31,7 @@ import kotlin.test.assertFailsWith
class RepositorySyncServerTest {
private val tempdir = Files.createTempDirectory("db")
- private val server = RepositorySyncServer(FileRepository(tempdir))
+ private val server = RepositorySyncServer(Repository(tempdir))
private val key = runBlocking { server.register() }
@Test
diff --git a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/repository/FileRepositoryTest.kt b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/sync/RepositoryTest.kt
similarity index 92%
rename from uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/repository/FileRepositoryTest.kt
rename to uhabits-server/src/test/kotlin/org/isoron/uhabits/server/sync/RepositoryTest.kt
index 589d56b2a..f29ad0605 100644
--- a/uhabits-server/src/test/kotlin/org/isoron/uhabits/sync/repository/FileRepositoryTest.kt
+++ b/uhabits-server/src/test/kotlin/org/isoron/uhabits/server/sync/RepositoryTest.kt
@@ -19,23 +19,23 @@
@file:Suppress("BlockingMethodInNonBlockingContext")
-package org.isoron.uhabits.sync.repository
+package org.isoron.uhabits.server.sync
import kotlinx.coroutines.runBlocking
import org.hamcrest.CoreMatchers.equalTo
-import org.isoron.uhabits.sync.SyncData
+import org.isoron.uhabits.core.sync.SyncData
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThat
import org.junit.Assert.assertTrue
import org.junit.Test
import java.nio.file.Files
-class FileRepositoryTest {
+class RepositoryTest {
@Test
fun testUsage() = runBlocking {
val tempdir = Files.createTempDirectory("db")!!
- val repo = FileRepository(tempdir)
+ val repo = Repository(tempdir)
val original = SyncData(10, "Hello world")
repo.put("abcdefg", original)