Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 830ae83

Browse files
committed
fix formatting, update tests
1 parent 9c1a48d commit 830ae83

File tree

10 files changed

+44
-41
lines changed

10 files changed

+44
-41
lines changed

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
### Versioning
1010

11-
1. Update version in `package_info.json`
12-
2. Build binaries via `bundleSQLiteStorage` task
11+
1. Update version in [package_info.json](package_info.json) AND [README.md](README.md)
12+
2. Build binaries via `bundleSQLiteStorage` gradle task
1313
3. Commit changes (name it `release: MAJOR.MINOR.PATCH`)
1414
4. Create tag (name it `MAJOR.MINOR.PATCH`)
1515
5. Push commit and tag to `main`

sqlite-storage/src/androidMain/kotlin/org/asyncstorage/sqlitestorage/AndroidDatabaseFile.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package org.asyncstorage.sqlitestorage
33
import java.io.File
44

55
internal class AndroidDatabaseFile(private val dbFile: File) : DatabaseFiles {
6-
override fun path(type: DatabaseFileType): String = when (type) {
7-
DatabaseFileType.Main -> dbFile.absolutePath
8-
DatabaseFileType.Wal -> "${dbFile.absolutePath}-wal"
9-
DatabaseFileType.Index -> "${dbFile.absolutePath}-shm"
10-
}
6+
override fun path(type: DatabaseFileType): String =
7+
when (type) {
8+
DatabaseFileType.Main -> dbFile.absolutePath
9+
DatabaseFileType.Wal -> "${dbFile.absolutePath}-wal"
10+
DatabaseFileType.Index -> "${dbFile.absolutePath}-shm"
11+
}
1112

1213
override fun dirPath(): String = dbFile.parentFile!!.absolutePath
1314

@@ -18,7 +19,7 @@ internal class AndroidDatabaseFile(private val dbFile: File) : DatabaseFiles {
1819
listOf(
1920
path(DatabaseFileType.Main),
2021
path(DatabaseFileType.Wal),
21-
path(DatabaseFileType.Index)
22+
path(DatabaseFileType.Index),
2223
).forEach { path ->
2324
deleted += File(path).delete()
2425
}

sqlite-storage/src/androidUnitTest/kotlin/org/asyncstorage/sqlitestorage/DatabaseFileTest.android.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class AndroidDatabaseFileTest {
2626
}
2727

2828
with(file.path(DatabaseFileType.Index)) {
29-
assert(this.endsWith("${dbName}-shm")) {
30-
"index path not matching, expected: ${dbName}-shm, received: $this"
29+
assert(this.endsWith("$dbName-shm")) {
30+
"index path not matching, expected: $dbName-shm, received: $this"
3131
}
3232
}
3333

3434
with(file.path(DatabaseFileType.Wal)) {
35-
assert(this.endsWith("${dbName}-wal")) {
36-
"wal path not matching, expected: ${dbName}-wal, received: $this"
35+
assert(this.endsWith("$dbName-wal")) {
36+
"wal path not matching, expected: $dbName-wal, received: $this"
3737
}
3838
}
3939
}

sqlite-storage/src/commonMain/kotlin/org/asyncstorage/sqlitestorage/DatabaseFiles.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.asyncstorage.sqlitestorage
22

3-
43
// todo: bring implementation to common, rather per platform
54
// requires per platform file access
65
interface DatabaseFiles {
@@ -32,5 +31,5 @@ interface DatabaseFiles {
3231
enum class DatabaseFileType {
3332
Main,
3433
Wal,
35-
Index
34+
Index,
3635
}

sqlite-storage/src/commonMain/kotlin/org/asyncstorage/sqlitestorage/DefaultSQLiteStorage.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ internal class DefaultSQLiteStorage(
6969
queries.deleteMany(keys)
7070
}
7171

72-
7372
override suspend fun merge(entry: Entry) =
7473
withContext(dispatcher) {
7574
queries.transactionWithResult {
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.asyncstorage.sqlitestorage
22

3-
import kotlin.native.ObjCName
4-
53
expect class SQLiteStorageFactory {
64
fun create(dbName: String): SQLiteStorage
75
}

sqlite-storage/src/commonTest/kotlin/org/asyncstorage/sqlitestorage/MergeTest.kt

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class MergeTest {
4343

4444
@Test
4545
fun merges_json_objects_deeply() {
46-
val old = """
46+
val old =
47+
"""
4748
{
4849
"a": 100,
4950
"b": true,
@@ -67,8 +68,9 @@ class MergeTest {
6768
}
6869
}
6970
}
70-
""".trimIndent()
71-
val new = """
71+
""".trimIndent()
72+
val new =
73+
"""
7274
{
7375
"b": false,
7476
"b1": "new",
@@ -91,8 +93,9 @@ class MergeTest {
9193
}
9294
}
9395
}
94-
""".trimIndent()
95-
val merged = """
96+
""".trimIndent()
97+
val merged =
98+
"""
9699
{
97100
"b": false,
98101
"b1": "new",
@@ -120,15 +123,16 @@ class MergeTest {
120123
},
121124
"a": 100
122125
}
123-
""".trimIndent()
126+
""".trimIndent()
124127

125128
val result = mergePossibleJsonValues(old, new)
126129
assertEquals(merged.prettyJson(), result!!.prettyJson())
127130
}
128131

129132
@Test
130133
fun merges_json_objects_deeply_2() {
131-
val original = """
134+
val original =
135+
"""
132136
{
133137
"index":0,
134138
"isActive":false,
@@ -153,8 +157,9 @@ class MergeTest {
153157
}
154158
}
155159
}
156-
""".trimIndent()
157-
val new = """
160+
""".trimIndent()
161+
val new =
162+
"""
158163
{
159164
"index":4,
160165
"isActive":true,
@@ -179,8 +184,9 @@ class MergeTest {
179184
}
180185
}
181186
}
182-
""".trimIndent()
183-
val merged = """
187+
""".trimIndent()
188+
val merged =
189+
"""
184190
{
185191
"index": 4,
186192
"isActive": true,
@@ -206,7 +212,7 @@ class MergeTest {
206212
},
207213
"name": "Johanna Sykes"
208214
}
209-
""".trimIndent()
215+
""".trimIndent()
210216
val result = mergePossibleJsonValues(original, new)
211217
assertEquals(merged.prettyJson(), result!!.prettyJson())
212218
}
@@ -220,12 +226,12 @@ class MergeTest {
220226
}
221227
}
222228

223-
224229
private fun String.prettyJson(): String {
225-
val json = Json {
226-
prettyPrint = true
227-
prettyPrintIndent = " "
228-
}
230+
val json =
231+
Json {
232+
prettyPrint = true
233+
prettyPrintIndent = " "
234+
}
229235
val el = json.parseToJsonElement(this)
230236
return json.encodeToString(el)
231237
}

sqlite-storage/src/iosMain/kotlin/org/asyncstorage/sqlitestorage/IosDatabaseFile.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal class IosDatabaseFile(private val dbName: String) : DatabaseFiles {
4343
listOf(
4444
path(DatabaseFileType.Main),
4545
path(DatabaseFileType.Wal),
46-
path(DatabaseFileType.Index)
46+
path(DatabaseFileType.Index),
4747
).forEach { file ->
4848
deleted += remove(file) == 0
4949
}

sqlite-storage/src/iosMain/kotlin/org/asyncstorage/sqlitestorage/SQLiteStorageFactory.ios.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ actual class SQLiteStorageFactory {
3131
version = AsyncStorageDB.Schema.version.toInt(),
3232
journalMode = JournalMode.WAL,
3333
extendedConfig =
34-
DatabaseConfiguration.Extended()
35-
.copy(
36-
synchronousFlag = SynchronousFlag.NORMAL,
37-
basePath = dbDirectory,
38-
),
34+
DatabaseConfiguration.Extended()
35+
.copy(
36+
synchronousFlag = SynchronousFlag.NORMAL,
37+
basePath = dbDirectory,
38+
),
3939
create = { connection ->
4040
wrapConnection(connection) { AsyncStorageDB.Schema.create(it) }
4141
},

sqlite-storage/src/iosTest/kotlin/org/asyncstorage/sqlitestorage/DatabaseFileTest.ios.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class IosDbUtilsTest {
1616
val dbName = "test-db"
1717
val file = createDatabaseFile(dbName)
1818
FileTestHelper.createFileAt(file.path())
19-
val parentDir = "/data/Library/Application Support/SqliteStorage/databases"
19+
val parentDir = "/data/Library/Application Support/SQLiteStorage/databases"
2020

2121
with(file.path()) {
2222
assert(this.endsWith("$parentDir/$dbName")) {

0 commit comments

Comments
 (0)