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

clippy: elide needless lifetime #154

Merged
merged 2 commits into from
Dec 2, 2024
Merged

Conversation

adam-cattermole
Copy link
Member

@adam-cattermole adam-cattermole commented Nov 28, 2024

New lint in 1.83 (we're pinned to 1.75 locally iirc but will hit this on PR)

Signed-off-by: Adam Cattermole <[email protected]>
@adam-cattermole adam-cattermole requested a review from a team as a code owner November 28, 2024 16:22
@adam-cattermole
Copy link
Member Author

adam-cattermole commented Nov 28, 2024

Looks like we're hitting the header re-ordering issue again in the integration tests... I'm wondering if this is in some way related to the cargo version as it passed 4 hours ago (on 1.82) and now fails (on 1.83).. I'll re-run a few times to check if it's failing consistently

@alexsnaps
Copy link
Member

Wondering if we should not assert against None, instead of the Some(&[u8])... This really doesn't buy us much.
If we had tests that whatever creates the message, creates the appropriate one (rather than the wire representation), that's all we'd need... like... an Operation returning the message :P

Signed-off-by: Adam Cattermole <[email protected]>
@adam-cattermole
Copy link
Member Author

I agree, and these have proven too much of a headache - I've removed in the latest commit.

In the refactor we should ideally use unit tests to check the messages (CheckRequest/RateLimitRequest) are created as expected, at which point checking these bytes is not overly valuable anyway. Curious on others thoughts though, @eguzki @didierofrivia happy with this (5f64ef5)?

Copy link
Member

@alexsnaps alexsnaps left a comment

Choose a reason for hiding this comment

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

🙌

testing the wire format representation is rarely a good idea... some json library do reshuffle or otherwise slightly change the input purposefully to avoid having users doing these checks... e.g. {"foo": 1, "bar": true} is equivalent to { "bar": true, "foo" :1}. Set semantic is usually a good candidate for these assumption to break... as was the case here.

@eguzki
Copy link
Contributor

eguzki commented Nov 29, 2024

n the refactor we should ideally use unit tests to check the messages (CheckRequest/RateLimitRequest) are created as expected, at which point checking these bytes is not overly valuable anyway

That's something I tried. It turns out that the crate type is crate-type = ["cdylib"] so integration test binaries cannot link to it. The workaround is to add yet another crate type lib, which would enable to do that. However, compilation would take double .

@alexsnaps
Copy link
Member

That's something I tried. It turns out that the crate type is crate-type = ["cdylib"] so integration test binaries cannot link to it.

No, that's unrelated... what @adam-cattermole is saying, have these assertions in unit tests just like all the other unit tests that exist already, not in integration tests.

@adam-cattermole
Copy link
Member Author

That's something I tried. It turns out that the crate type is crate-type = ["cdylib"] so integration test binaries cannot link to it.

I was more thinking unit tests not integration, where we test the parts of the application work without the "filter" bits

@eguzki
Copy link
Contributor

eguzki commented Nov 29, 2024

happy with this (5f64ef5)?

TBH not really. What I want to assert is on the descriptor entries being sent to the wire. Obviously we are failing to do that now, so this change is just saving some headache.. but I wanted to highlight that this is still a tech debt.. "I want to assert that I send descriptor entries A1 == B1 and A2 == B2"

@alexsnaps
Copy link
Member

"I want to assert that I send descriptor entries A1 == B1 and A2 == B2"

Right, and that doesn't need to be an integration test. This is currently tested for at the wrong abstraction layer.

@adam-cattermole
Copy link
Member Author

adam-cattermole commented Nov 29, 2024

What I want to assert is on the descriptor entries being sent to the wire

I guess what I'm suggesting is that if we can get to a point where we have a separation of the "filtercontext" code from the part that is processing an action/operation we can unit test that a message is being created correctly... rather than integration testing that it's being created and then serialized

@adam-cattermole adam-cattermole merged commit 801911b into main Dec 2, 2024
13 checks passed
@adam-cattermole adam-cattermole deleted the clippy-elide-lifetime branch December 2, 2024 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants