Skip to content

feat: reload networkmock config without restarting the app - #124

Open
MaxMichel2 wants to merge 1 commit into
fix/networkmock-kermit-loggingfrom
feat/networkmock-spec-reload
Open

MaxMichel2 wants to merge 1 commit into
fix/networkmock-kermit-loggingfrom
feat/networkmock-spec-reload

Conversation

@MaxMichel2

Copy link
Copy Markdown
Collaborator

Summary

Closes #90.

Stacked on #123 (both touch MockConfigRepository/NetworkMockPlugin's logging) — this PR's own diff is the last 12 files; merge #123 first.

MockConfigRepository caches its parsed OpenAPI configuration forever after the first successful load, with no way to invalidate it. A developer editing a spec file on disk had no way to see the change without restarting the app — a meaningfully worse dev-loop than most of what this tool exists to speed up.

What changed

  • MockConfigRepository.invalidate(): clears the cached config and response index, forcing the next loadConfiguration() (or anything that calls it internally, like findMatchingMock) to re-read and re-parse every configured spec from scratch.
  • NetworkMockViewModel.reloadConfiguration(): invalidates then reloads, re-registering the (possibly changed) set of operations so write-side helpers stay in sync.
  • A new "Reload Config" toolbar action in NetworkMock, wired the same way as the existing "Reset to Network" action — a capacity-1 MutableSharedFlow, collected in a LaunchedEffect in NetworkMockScreen.
  • Operations added, removed, or renamed in the spec appear immediately after reloading. Persisted per-operation mock selections are untouched. The operation sheet, if open, is unaffected by the reload.

Public API

New public members — api.txt regenerated via metalavaGenerateSignature:

  • devview-networkmock-core: MockConfigRepository.invalidate()
  • devview-networkmock: NetworkMockViewModel.reloadConfiguration(), and NetworkMockScreen gained a new required reloadConfigSharedFlow parameter (no other call sites existed outside NetworkMock.kt, which is updated).

Docs updated: networkmock-core.md (new "Caching & Reload" section), networkmock-ui.md (Screens), networkmock-workflows.md (new "Reloading a spec after editing it" section).

Tests

  • MockConfigRepositoryTest: invalidate forces a re-read (call-count assertion), and invalidate + reload picks up a changed spec file (operation list assertion via a new MutableResourceLoader fixture).
  • NetworkMockViewModelTest: reloadConfiguration() invalidates then reloads, verified via coVerifyOrder.

Verification

.\gradlew.bat detektFull -Pandroidx.baselineprofile.skipgeneration
.\gradlew.bat cleanTestAndroidHostTest testAndroidHostTest -Pandroidx.baselineprofile.skipgeneration
.\gradlew.bat :konsist:test -Pandroidx.baselineprofile.skipgeneration
.\gradlew.bat :sample:androidApp:assembleDebug -Pandroidx.baselineprofile.skipgeneration

All green.

🤖 Generated with Claude Code

MockConfigRepository caches the parsed OpenAPI config forever after the
first successful load, with no way to invalidate it - a developer
editing a spec file had to restart the app to see the change.

- MockConfigRepository.invalidate(): clears the cached config and
  response index, forcing the next loadConfiguration() to re-read and
  re-parse every spec from scratch.
- NetworkMockViewModel.reloadConfiguration(): invalidates then reloads,
  re-registering the (possibly changed) set of operations.
- A new 'Reload Config' toolbar action in NetworkMock, wired the same
  way as the existing 'Reset to Network' action (SharedFlow ->
  LaunchedEffect -> ViewModel call).

Operations added, removed, or renamed in the spec appear immediately
after reloading; persisted per-operation mock selections are untouched.

Closes #90.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant