Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement remoteAddress0 and localAddress0 on EmbeddedChannel #2345

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

FranzBusch
Copy link
Member

Motivation

EmbeddedChannel is often used in testing and currently any code under testing that uses context.localAddress cannot be mocked, since EmbeddedChannelCore is always throwing.

Modification

Use the same values for localAddress in localAddress0(). Same for remoteAddress

Result

We can now properly test code that needs local/remote addresses with EmbeddedChannel

@Lukasa Lukasa added the semver/patch No public API change. label Jan 11, 2023
Sources/NIOEmbedded/Embedded.swift Outdated Show resolved Hide resolved
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Good stuff, thanks!

@Lukasa Lukasa enabled auto-merge (squash) January 11, 2023 18:00
# Motivation
`EmbeddedChannel` is often used in testing and currently any code under testing that uses `context.localAddress` cannot be mocked, since `EmbeddedChannelCore` is always throwing.

# Modification
Use the same values for `localAddress` in `localAddress0()`. Same for `remoteAddress`

# Result
We can now properly test code that needs local/remote addresses with `EmbeddedChannel`
@Lukasa Lukasa merged commit 602989b into apple:main Jan 12, 2023
@FranzBusch FranzBusch deleted the fb-embedded-addresses branch January 12, 2023 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants