Skip to content

test: clean ip tests #4632

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

test: clean ip tests #4632

wants to merge 15 commits into from

Conversation

wooorm-arcjet
Copy link
Member

In the IP tests, there were functions making functions making objects making assertions.
It was difficult to wrap my head around what was going on.
Functions have some benefits but also makes it hard to keep track of what’s going on, creating arguably potentially smelly code.
The alternative is to be a bit more verbose in each test case. Less functions to build things. Loops and arrays for repetition.
I did that.

Some examples of arguable smells were:

That being said, I importantly did not change the tests. Didn’t add, move, or remove. But there is room for that.
I do wonder whether we really need to test every potential valid/invalid IP (64 tests) at every header or other property in the request.
More important seems a split around platforms, to test that most headers are not supported if a platform is set. Which is documented in the code but currently not tested.

Still, for the same number of lines, I do think it’s now more obvious what is going on.
I left the commits so work progress can be seen, but that shows a lot of the in-between-state, I’d recommend side by side.

@wooorm-arcjet wooorm-arcjet requested a review from a team as a code owner July 15, 2025 14:30
Copy link

trunk-io bot commented Jul 15, 2025

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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