aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-android/app/src/test/kotlin/org/meshbay
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-10 16:15:48 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-10 16:15:48 +0200
commit24547e4efd3a45b36b3bea8c29cfc687230a6d3a (patch)
tree05aed558b665841230b0a1b4d2f987091c573ab8 /packages/meshbay-android/app/src/test/kotlin/org/meshbay
parent1c97ffb91bb4928022e995709d7e55b19cfd18eb (diff)
downloadmeshbay-24547e4efd3a45b36b3bea8c29cfc687230a6d3a.tar.gz
feat(android): send a manifest of what each backup run sent
Photos, videos and files record, per file, their path on the node, their path and album on the phone, dates, size and SHA-256, uploaded as meshbay-manifest/manifest-<date>.jsonl once the run is done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-android/app/src/test/kotlin/org/meshbay')
-rw-r--r--packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/ManifestLogTest.kt52
1 files changed, 52 insertions, 0 deletions
diff --git a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/ManifestLogTest.kt b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/ManifestLogTest.kt
new file mode 100644
index 0000000..bb3a67f
--- /dev/null
+++ b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/ManifestLogTest.kt
@@ -0,0 +1,52 @@
+package org.meshbay.client
+
+import org.json.JSONObject
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TemporaryFolder
+import org.meshbay.client.phonesync.ManifestLog
+import java.io.File
+import java.util.TimeZone
+
+class ManifestLogTest {
+ @get:Rule val tmp = TemporaryFolder()
+
+ private fun line(n: Int) = JSONObject().put("node", "d/$n.jpg").put("source", "DCIM/Camera/$n.jpg")
+
+ private fun nodes(f: File) = f.readLines().filter { it.isNotBlank() }.map { JSONObject(it).getString("node") }
+
+ @Test fun `nothing waiting means nothing to send`() {
+ val log = ManifestLog(File(tmp.root, "m"))
+ assertFalse(log.waiting())
+ assertNull(log.issue())
+ }
+
+ @Test fun `what was sent is described once the node has the manifest, and only then forgotten`() {
+ val log = ManifestLog(File(tmp.root, "m"))
+ log.append(line(1)); log.append(line(2))
+ assertTrue(log.waiting())
+ assertEquals(listOf("d/1.jpg", "d/2.jpg"), nodes(log.issue()!!))
+ log.confirm()
+ assertFalse(log.waiting())
+ assertNull(log.issue())
+ }
+
+ @Test fun `a manifest that did not arrive goes again, with what came since`() {
+ val log = ManifestLog(File(tmp.root, "m"))
+ log.append(line(1))
+ log.issue() // sent, never confirmed: the run was cut short
+ log.append(line(2))
+ val again = ManifestLog(File(tmp.root, "m")) // a restart in between
+ assertTrue(again.waiting())
+ assertEquals(listOf("d/1.jpg", "d/2.jpg"), nodes(again.issue()!!))
+ }
+
+ @Test fun `manifests are named for when they were written`() {
+ assertEquals("manifest-2026-10-09-120000.jsonl",
+ ManifestLog.nameFor(1791547200000L, TimeZone.getTimeZone("UTC")))
+ }
+}