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

Normalize line endings for comparing responses in tests #575

Merged
merged 1 commit into from
Mar 30, 2017

Conversation

yunyu
Copy link
Contributor

@yunyu yunyu commented Mar 29, 2017

This fixes most template engine tests failing on Windows if git autocrlf is enabled (default). Directly comparing the buffer strings broke the test, so I opted to normalize the buffer (adapted from Netty's LineBasedFrameDecoder) instead. I don't forsee any issues with this change, as different styles of line endings are irrelevant in tests anyways.

@@ -125,7 +125,7 @@ protected void testRequestBuffer(HttpClient client, HttpMethod method, int port,
latch.countDown();
} else {
resp.bodyHandler(buff -> {
assertEquals(responseBodyBuffer, buff);
assertEquals(responseBodyBuffer, normalizeLineEndingsFor(buff));
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for being annoying :) what about having a flag to enable this on demand? For example if one is testing file downloads with binary payload this could again modify the payload.

Copy link
Contributor Author

@yunyu yunyu Mar 29, 2017

Choose a reason for hiding this comment

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

I can get testRequest (which takes in a string) to pass a boolean to testRequestBuffer. Unfortunately I have class and it will take a bit.

Copy link
Member

Choose a reason for hiding this comment

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

@yunyul sure no problem!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've revised the commit by adding a parameter that's only default true if a string-based testRequest is called.

This fixes most template engine tests failing on Windows. Only response bodies passed as strings will be normalized.
@yunyu yunyu force-pushed the normalize-line-endings-in-tests branch from 4e671c2 to 6c259b8 Compare March 29, 2017 15:03
@alexlehm
Copy link
Contributor

+1

@pmlopes pmlopes merged commit 508c6cb into vert-x3:master Mar 30, 2017
@pmlopes pmlopes removed the to review label Mar 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants