mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-04 16:06:41 +00:00
fix: log why a device sync run failed #34
The sync adapter logged only the SyncResult counters of a run, so a failed sync showed up in logcat as `ioErrors=1` and nothing else. The reason was in the run's report, and JS warnings from a headless run don't reach logcat; finding out that a run failed on "Invalid column raw_contact_is_read_only" took reading the app's storage. The log line now carries the report's outcome, its message (up to 300 characters) and the number of failed items. Checked: 55 JVM tests (`gradlew :app:testDebugUnitTest`, one new) and the debug build.
This commit is contained in:
@@ -81,4 +81,19 @@ class SyncReportsTest {
|
||||
fun `an outcome this build does not know is retried`() {
|
||||
assertEquals(1L, SyncReports.outcome(report("somethingNew"), "reported").ioErrors)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the log summary names the outcome, failed items and the message`() {
|
||||
assertEquals("outcome=ok", SyncReports.summary(report("ok")))
|
||||
assertEquals(
|
||||
"outcome=internal message=Invalid column x",
|
||||
SyncReports.summary(report("internal", ",\"message\":\"Invalid column x\"")),
|
||||
)
|
||||
val withItems = report("ok").replace("\"itemErrors\":[]", "\"itemErrors\":[{\"ref\":\"a\"},{\"ref\":\"b\"}]")
|
||||
assertEquals("outcome=ok itemErrors=2", SyncReports.summary(withItems))
|
||||
assertEquals("no report", SyncReports.summary(null))
|
||||
assertEquals("unreadable report", SyncReports.summary("{"))
|
||||
val long = SyncReports.summary(report("io", ",\"message\":\"" + "m".repeat(400) + "\""))
|
||||
assertEquals("outcome=io message=".length + 300, long.length)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user