Skip to content

suggestions for PR32#33

Open
germ-mark wants to merge 3 commits into
feat/testing-mocksfrom
feat/testing-mocks-suggestions
Open

suggestions for PR32#33
germ-mark wants to merge 3 commits into
feat/testing-mocksfrom
feat/testing-mocks-suggestions

Conversation

@germ-mark

Copy link
Copy Markdown
Contributor

Implemented the GermConvenienceMocks breakout and checked sendable MockHTTPFetcher as I suggested in that PR

Noticed that the package structure has ballooned a bit; collected all the test helpers within the mocks target, and all tests in a single test target

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 25f2fda

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

#expect(mock.requests(for: tokenUrl) == [request])
#expect(try mock.firstRequest(for: tokenUrl) == request)
#expect(await mock.requests(for: tokenUrl) == [request])
#expect(try await mock.firstRequest(for: tokenUrl) == request)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these need awaits? They're not async?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the MockHTTPFetcher is now an actor instead of a class, so all calls into the actor may possibly suspend to deconflict concurrent access to its internal state.

This is to address the @unchecked Sendable. Which might be fine in local code if we know it will only ever be used synchronously. A public mock should probably properly be thread-safe(sendable).

  • making the MockHTTPFetcher an actor is the way I chose here. has the risk of introducing suspension points, but if it's being used sequentially without shared access shouldn't need to suspend
  • could, alternatively, serialize access to MockHTTPFetcher by requiring it to run on the main thread with MainActor

import GermConvenience
import HTTPTypes

extension BundledHTTPRequest: Equatable {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@germ-mark shouldn't this move up into GermConvenience core?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • is there a use for comparing BundledHTTPRequest's? I think this was defined for use in test, which is also may be why it performs a limited equality
  • should the equality check compare the body?

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.

2 participants