Add unit tests for EnhancementQueueWorker and EnhancementQueueScheduler (#139) #141
No reviewers
Labels
No labels
blocked:children
blocked:needs-decision
blocked:needs-human
blocked:verify-failed
bug
deferred
enhancement
feature-request
in-progress
needs-decompose
needs-triage
quickfix
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/transcriber!141
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/enhancement-queue-tests-139"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes Mark/transcriber#139 — adds unit tests for
EnhancementQueueWorker,EnhancementQueueScheduler, andEnhancementJobRepository.Seam refactor
No seam refactor was needed.
EnhancementQueueWorkeris fully constructor-injected (@HiltWorker @AssistedInject) with zero static WorkManager references, so it is unit-testable on the plain JVM.EnhancementQueueScheduler.schedule()callsWorkManager.getInstance(context)statically, but that call is already covered by Robolectric-freemockStaticmocking inEnhancementQueueSchedulerTest(plain JUnit 4). The only build change istestImplementation("org.json:json:20240303")soLLMSummarizer's JSON fallback path runs against a realJSONObjecton the JVM test classpath instead of theandroid.jarstubs.New test files
app/src/test/java/com/voicetranscriber/service/EnhancementQueueWorkerTest.kt— 9 tests: no-pending-jobs no-op (Result.success()+verifyNoInteractions); per-FeatureTypedispatch (diarization, topic extraction, summarization, title generation) asserting each branch's handler effects via Mockito verify; attempt-count increment withMAX_ATTEMPTS->FAILEDtransition through theFakeEnhancementJobDao-backed real repository; terminalResults matching the current rollup contract (transientFAILED_RETRYABLE->Result.retry(), permanentFAILED->Result.success()). This PR aligns the three failure-message assertions with the persistede.messagebehavior introduced in35eeb93(the worker now stores the underlying exception message instead of the generic "Permanent failure").app/src/test/java/com/voicetranscriber/service/EnhancementQueueSchedulerTest.kt— 3 tests: one-time (non-periodic) enqueue;WorkSpec.requiredNetworkType == NetworkType.CONNECTED; uniqueWORK_NAME+ExistingWorkPolicy.KEEP; backoff EXPONENTIAL 30s; input dataData.EMPTY(the scheduler is repository-driven — the worker discovers pending jobs at run time, no job id/job type is passed via WorkManager input data).app/src/test/java/com/voicetranscriber/data/repository/EnhancementJobRepositoryTest.kt— 14 tests: happy-path CRUD (insert/get/update/delete/listByStatus), duplicate primary-key insert throwsSQLiteConstraintException(Room ABORT default), unknown-session/empty queries return empty,getPendingCount,cancelPendingJobsForSession,hasPendingJob.app/src/test/java/com/voicetranscriber/data/database/dao/FakeEnhancementJobDao.kt— reusable in-memory fake backing the repository and worker tests.Test command output
Suite result (11 classes, 105 tests — 0 failures, 0 errors, 0 skipped):