refactor(progress): ProgressService required at construction; delete the 9 unreachable erase-fallbacks
Batch H1 step 3a. The ceiling census (exhaustive UpdateUniversalProgress
grep) found 9 nil-guarded `if progressSvc != nil { funnel } else { raw
erase-write }` fallbacks — the survey's "four" under-counted kobo.go,
which has FOUR sites (Markup ReadingSync, Markup last-read-place,
AnalyticsGettests, SyncFromServer), plus one each in media.go, queue.go
and koreader.go. All unreachable: the service is created unconditionally
at main.go:127 and wired into every handler and the queue processor; the
test harness wires them too.
The erasure pattern is now unrepresentable:
- NewMediaHandler / NewKOReaderHandler / NewKoboHandler / both
NewSyncQueueProcessor flavors take the ProgressService as a REQUIRED
constructor arg; the SetProgressService setters are gone.
- Every fallback body (raw UpdateUniversalProgress with explicit-NULL
pgtypes for viewport/scroll/panel/reading_mode/zoom and no
audio_offset_seconds/context_text) is deleted; each write funnels
through SaveProgress with the LWW seed, so fields the writer doesn't
know survive.
- Removed the now-dead koreader pg-type helpers (textPtrToPgText,
intPtrToPgInt4, int64PtrToPgInt8) and their self-tests.
Behavior deltas (stored-row content, no wire shape changes —
KOReader/Kobo response pins stayed green):
- KOReader fallback used to write explicit NULL viewports and drop the
context_text the koplugin sends; the funneled mainline already maps
book.ContextText.
- Queue flushes no longer overwrite chapter_progress with the book
percentage (bogus data; preserved via the seed).
- A web PUT without percentage no longer writes 0% via the deleted
fallback; percentage seeds from the stored row.
Contract suite: KOReader×4 + Kobo×3 pins green.
This commit is contained in:
1 parent
28bd323505
commit
e83c00f869
9 files changed
+163
-419
No files matched your search
@@ -30,51 +30,6 @@ func TestGetDeviceIcon_Unknown(t *testing.T) {
|
||||
assert.Equal(t, "📚", result)
|
||||
}
|
||||
|
||||
func TestTextPtrToPgText(t *testing.T) {
|
||||
t.Run("nil returns invalid", func(t *testing.T) {
|
||||
result := textPtrToPgText(nil)
|
||||
assert.False(t, result.Valid)
|
||||
})
|
||||
t.Run("non-nil returns valid", func(t *testing.T) {
|
||||
s := "epubcfi(/6/4/2:10)"
|
||||
result := textPtrToPgText(&s)
|
||||
assert.True(t, result.Valid)
|
||||
assert.Equal(t, s, result.String)
|
||||
})
|
||||
t.Run("empty string returns valid", func(t *testing.T) {
|
||||
s := ""
|
||||
result := textPtrToPgText(&s)
|
||||
assert.True(t, result.Valid)
|
||||
assert.Equal(t, "", result.String)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIntPtrToPgInt4(t *testing.T) {
|
||||
t.Run("nil returns invalid", func(t *testing.T) {
|
||||
result := intPtrToPgInt4(nil)
|
||||
assert.False(t, result.Valid)
|
||||
})
|
||||
t.Run("non-nil returns valid", func(t *testing.T) {
|
||||
v := 5
|
||||
result := intPtrToPgInt4(&v)
|
||||
assert.True(t, result.Valid)
|
||||
assert.Equal(t, int32(5), result.Int32)
|
||||
})
|
||||
}
|
||||
|
||||
func TestInt64PtrToPgInt8(t *testing.T) {
|
||||
t.Run("nil returns invalid", func(t *testing.T) {
|
||||
result := int64PtrToPgInt8(nil)
|
||||
assert.False(t, result.Valid)
|
||||
})
|
||||
t.Run("non-nil returns valid", func(t *testing.T) {
|
||||
v := int64(10000)
|
||||
result := int64PtrToPgInt8(&v)
|
||||
assert.True(t, result.Valid)
|
||||
assert.Equal(t, int64(10000), result.Int64)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFloat64PtrHelpers(t *testing.T) {
|
||||
t.Run("pgtype float64 valid", func(t *testing.T) {
|
||||
v := pgtype.Float8{Float64: 0.5, Valid: true}
|
||||
|
||||
Reference in new issue
Block a user