aboutsummaryrefslogtreecommitdiff
path: root/app/src/test/java/invalid/lena
diff options
context:
space:
mode:
authorLena <lena@omega>2026-08-23 00:00:00 +0000
committerLena <lena@omega>2026-08-23 00:00:00 +0000
commitdc0338f8c0c9e74b277169d812c432f7ea4888e3 (patch)
tree2ab4a1157e07b4f36c060a1300ae85540ef39cf2 /app/src/test/java/invalid/lena
parentf6706d04bd347465f9db1e484007db215100d965 (diff)
downloadrsend-dc0338f8c0c9e74b277169d812c432f7ea4888e3.tar.gz
app: rename RsyncRunner to Rsync
Runner names the architecture rather than the thing. The object is the rsync invocation.
Diffstat (limited to 'app/src/test/java/invalid/lena')
-rw-r--r--app/src/test/java/invalid/lena/rsend/RsyncTest.kt (renamed from app/src/test/java/invalid/lena/rsend/RsyncRunnerTest.kt)50
1 files changed, 25 insertions, 25 deletions
diff --git a/app/src/test/java/invalid/lena/rsend/RsyncRunnerTest.kt b/app/src/test/java/invalid/lena/rsend/RsyncTest.kt
index b2cf906..3ca8dcc 100644
--- a/app/src/test/java/invalid/lena/rsend/RsyncRunnerTest.kt
+++ b/app/src/test/java/invalid/lena/rsend/RsyncTest.kt
@@ -6,7 +6,7 @@ import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
-class RsyncRunnerTest {
+class RsyncTest {
private val remote = Remote("nas", "host", 22, "user")
@@ -14,7 +14,7 @@ class RsyncRunnerTest {
// surface of the app: any change to it should be a deliberate edit here.
@Test
fun basicArgs() {
- val a = RsyncRunner.args("RSH", remote, Folder(name = "n", local = "/a", remoteName = "nas", remotePath = "/b"))
+ val a = Rsync.args("RSH", remote, Folder(name = "n", local = "/a", remoteName = "nas", remotePath = "/b"))
assertEquals(
listOf(
"-rt", "--out-format=%o %n", "--partial-dir=.rsend-partial", "--timeout=300",
@@ -29,8 +29,8 @@ class RsyncRunnerTest {
// name, so an interrupted sync destroys a complete remote copy.
@Test
fun partialsStayOutOfTheDestinationName() {
- val a = RsyncRunner.args("RSH", remote, Folder(local = "/a", remotePath = "/b"))
- assertTrue(a.contains("--partial-dir=${RsyncRunner.PARTIAL_DIR}"))
+ val a = Rsync.args("RSH", remote, Folder(local = "/a", remotePath = "/b"))
+ assertTrue(a.contains("--partial-dir=${Rsync.PARTIAL_DIR}"))
assertFalse(a.contains("--partial"))
}
@@ -41,7 +41,7 @@ class RsyncRunnerTest {
// --log-format, which every rsync understands.
@Test
fun outputIsLabelledWithTheOperation() {
- val a = RsyncRunner.args("RSH", remote, Folder(local = "/a", remotePath = "/b", delete = true))
+ val a = Rsync.args("RSH", remote, Folder(local = "/a", remotePath = "/b", delete = true))
assertTrue(a.contains("--out-format=%o %n"))
assertFalse(a.contains("-v"))
assertFalse(a.any { it.startsWith("--info") })
@@ -52,7 +52,7 @@ class RsyncRunnerTest {
// rename on the phone plus one interruption would leave neither copy.
@Test
fun mirrorDeletesOnlyAfterEverythingIsTransferred() {
- val a = RsyncRunner.args("RSH", remote, Folder(local = "/a", remotePath = "/b", delete = true))
+ val a = Rsync.args("RSH", remote, Folder(local = "/a", remotePath = "/b", delete = true))
assertTrue(a.contains("--delete-after"))
assertFalse(a.contains("--delete"))
}
@@ -60,14 +60,14 @@ class RsyncRunnerTest {
@Test
fun additiveOmitsDelete() {
assertFalse(
- RsyncRunner.args("RSH", remote, Folder(local = "/a", remotePath = "/b", delete = false))
+ Rsync.args("RSH", remote, Folder(local = "/a", remotePath = "/b", delete = false))
.any { it.startsWith("--delete") }
)
}
@Test
fun excludesBecomeFlags() {
- val a = RsyncRunner.args("RSH", remote, Folder(local = "/a", remotePath = "/b", excludes = listOf(".x/", ".y")))
+ val a = Rsync.args("RSH", remote, Folder(local = "/a", remotePath = "/b", excludes = listOf(".x/", ".y")))
assertTrue(a.contains("--exclude=.x/"))
assertTrue(a.contains("--exclude=.y"))
}
@@ -77,23 +77,23 @@ class RsyncRunnerTest {
@Test
fun ipv6DestinationIsBracketed() {
val v6 = Remote("nas", "2001:db8::1", 22, "user")
- val a = RsyncRunner.args("RSH", v6, Folder(local = "/a", remotePath = "/b"))
+ val a = Rsync.args("RSH", v6, Folder(local = "/a", remotePath = "/b"))
assertTrue(a.contains("user@[2001:db8::1]:/b/"))
// A hostname must not gain brackets.
- assertTrue(RsyncRunner.args("RSH", remote, Folder(local = "/a", remotePath = "/b"))
+ assertTrue(Rsync.args("RSH", remote, Folder(local = "/a", remotePath = "/b"))
.contains("user@host:/b/"))
}
@Test
fun trailingSlashIdempotent() {
- val a = RsyncRunner.args("RSH", remote, Folder(local = "/a/", remotePath = "/b/"))
+ val a = Rsync.args("RSH", remote, Folder(local = "/a/", remotePath = "/b/"))
assertTrue(a.contains("/a/"))
assertTrue(a.contains("user@host:/b/"))
}
@Test(expected = IllegalArgumentException::class)
fun daemonStyleRemotePathIsRejectedAtExecution() {
- RsyncRunner.args("RSH", remote, Folder(local = "/a", remotePath = ":module"))
+ Rsync.args("RSH", remote, Folder(local = "/a", remotePath = ":module"))
}
// Exit 24 is "some files vanished before they could be transferred", which
@@ -102,29 +102,29 @@ class RsyncRunnerTest {
// that directory's contents on the server, so it must not read as success.
@Test
fun vanishedSourceFilesAreNotAFailureForAdditive() {
- assertTrue(RsyncRunner.succeeded(0, mirror = false))
- assertTrue(RsyncRunner.succeeded(24, mirror = false))
- assertFalse(RsyncRunner.succeeded(23, mirror = false))
- assertFalse(RsyncRunner.succeeded(12, mirror = false))
- assertFalse(RsyncRunner.succeeded(1, mirror = false))
+ assertTrue(Rsync.succeeded(0, mirror = false))
+ assertTrue(Rsync.succeeded(24, mirror = false))
+ assertFalse(Rsync.succeeded(23, mirror = false))
+ assertFalse(Rsync.succeeded(12, mirror = false))
+ assertFalse(Rsync.succeeded(1, mirror = false))
}
@Test
fun vanishedSourceFilesFailAMirror() {
- assertTrue(RsyncRunner.succeeded(0, mirror = true))
- assertFalse(RsyncRunner.succeeded(24, mirror = true))
- assertFalse(RsyncRunner.succeeded(23, mirror = true))
+ assertTrue(Rsync.succeeded(0, mirror = true))
+ assertFalse(Rsync.succeeded(24, mirror = true))
+ assertFalse(Rsync.succeeded(23, mirror = true))
}
@Test
fun outputLinesAreBoundedWithoutBlockingTheNextLine() {
- val hostile = ByteArray(RsyncRunner.MAX_OUTPUT_LINE_BYTES * 8) { 'x'.code.toByte() }
+ val hostile = ByteArray(Rsync.MAX_OUTPUT_LINE_BYTES * 8) { 'x'.code.toByte() }
val input = ByteArrayInputStream(hostile + "\nsend next\n".toByteArray())
val lines = ArrayList<String>()
- RsyncRunner.boundedLines(input, lines::add)
+ Rsync.boundedLines(input, lines::add)
assertEquals(2, lines.size)
assertTrue(lines[0].endsWith("[truncated]"))
- assertTrue(lines[0].length <= RsyncRunner.MAX_OUTPUT_LINE_BYTES + 20)
+ assertTrue(lines[0].length <= Rsync.MAX_OUTPUT_LINE_BYTES + 20)
assertEquals("send next", lines[1])
}
@@ -143,7 +143,7 @@ class RsyncRunnerTest {
rsync: some error worth keeping
""".trimIndent() + "\n"
val logged = ArrayList<String>()
- val t = RsyncRunner.tally(ByteArrayInputStream(out.toByteArray()), logged::add)
+ val t = Rsync.tally(ByteArrayInputStream(out.toByteArray()), logged::add)
assertEquals(2L, t.sent)
assertEquals(3L, t.deleted)
@@ -157,7 +157,7 @@ class RsyncRunnerTest {
@Test
fun unreachableMarkerIsDetected() {
val out = "rsh: unreachable: dial tcp 10.0.0.1:22: i/o timeout\n"
- val t = RsyncRunner.tally(ByteArrayInputStream(out.toByteArray())) {}
+ val t = Rsync.tally(ByteArrayInputStream(out.toByteArray())) {}
assertTrue(t.unreachable)
assertEquals(0L, t.deleted)
}