Skip to content

refactor: make MockHttpClientCall internal #89

Description

@MaxMichel2

Summary

MockHttpClientCall is a public class purely because Ktor's HttpClientCall(client) base constructor requires it to be instantiable from the plugin's install code — it should be internal. This is independent of the OpenAPI migration (tracked in the epic, #72) and can be picked up any time. Good first issue: small, self-contained, mechanical.

Current state

MockHttpClientCall (devview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.kt:356-408) is declared public class MockHttpClientCall(client: HttpClient) : HttpClientCall(client). It's part of the tracked public API surface (devview-networkmock-ktor/api/api.txt), but nothing about it is meant to be integrator-facing — it's an internal implementation detail of how the plugin fabricates a synthetic response. Its rawContent override is annotated @InternalAPI (:390-393), meaning it already depends on a Ktor API that isn't stable — being public compounds that risk, since any breaking change to Ktor's internals here would be a breaking change to this library's public API too, for a type integrators have no legitimate reason to construct themselves.

What to build

  • Change MockHttpClientCall's visibility to internal.
  • Verify this compiles — createMockHttpClientCall (:322-346), the only caller, is a private top-level function in the same file, so this should be a clean visibility narrowing with no call-site changes needed elsewhere.
  • Confirm no test or sample code constructs MockHttpClientCall directly (check devview-networkmock-ktor/src/androidHostTest/... and sample/network/...) — if something does, that usage needs to move to a public entry point (or the test needs restructuring to not require direct construction).

Acceptance criteria

  • MockHttpClientCall is internal, not public.
  • devview-networkmock-ktor/api/api.txt is regenerated and no longer lists MockHttpClientCall.
  • All existing tests still pass without needing to construct MockHttpClientCall directly.

Files likely touched

  • devview-networkmock-ktor/src/commonMain/kotlin/com/worldline/devview/networkmock/ktor/plugin/NetworkMockPlugin.kt
  • devview-networkmock-ktor/api/api.txt

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions