Implement background media ingestion and Pi deployment
Android / test-and-build (push) Canceled after 0s
Server / deployment-config (push) Canceled after 0s
Server / vulnerability-scan (push) Canceled after 0s

This commit is contained in:
Курнат Андрей
2026-07-15 22:58:03 +03:00
parent 8da166fb6b
commit e48e1e36a5
32 changed files with 825 additions and 76 deletions
@@ -0,0 +1,53 @@
/**
* qsfera Android client application
*
* Copyright (C) 2026 QSfera.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*/
package eu.qsfera.android.workers
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class AutomaticUploadsWorkerTest {
private val sourceUri = "content://camera/photo.jpg"
@Test
fun `completed upload identifies original source`() {
assertTrue(
shouldRemovePreviouslyUploadedSource(
sourceUri = sourceUri,
lastModified = 1_000,
completedUploadTimesBySourceUri = mapOf(sourceUri to 2_000),
)
)
}
@Test
fun `new file reusing uri is not treated as uploaded source`() {
assertFalse(
shouldRemovePreviouslyUploadedSource(
sourceUri = sourceUri,
lastModified = 3_000,
completedUploadTimesBySourceUri = mapOf(sourceUri to 2_000),
)
)
}
@Test
fun `unknown modification time is not deleted`() {
assertFalse(
shouldRemovePreviouslyUploadedSource(
sourceUri = sourceUri,
lastModified = 0,
completedUploadTimesBySourceUri = mapOf(sourceUri to 2_000),
)
)
}
}
@@ -0,0 +1,47 @@
/**
* qsfera Android client application
*
* Copyright (C) 2026 QSfera.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*/
package eu.qsfera.android.workers
import androidx.documentfile.provider.DocumentFile
import io.mockk.every
import io.mockk.mockk
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class RemoveSourceFileWorkerTest {
@Test
fun `missing source is already removed`() {
val documentFile = mockk<DocumentFile>()
every { documentFile.exists() } returns false
assertTrue(removeSourceDocument(documentFile))
}
@Test
fun `successful delete removes source`() {
val documentFile = mockk<DocumentFile>()
every { documentFile.exists() } returns true
every { documentFile.delete() } returns true
assertTrue(removeSourceDocument(documentFile))
}
@Test
fun `failed delete requests another attempt`() {
val documentFile = mockk<DocumentFile>()
every { documentFile.exists() } returnsMany listOf(true, true)
every { documentFile.delete() } returns false
assertFalse(removeSourceDocument(documentFile))
}
}