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

feat: add JSON request/response support #80

Merged
merged 1 commit into from
Nov 27, 2024
Merged

feat: add JSON request/response support #80

merged 1 commit into from
Nov 27, 2024

Conversation

m4tx
Copy link
Contributor

@m4tx m4tx commented Nov 27, 2024

No description provided.

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 87.17949% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
flareon/src/test.rs 18.18% 9 Missing ⚠️
flareon/src/response.rs 95.45% 1 Missing ⚠️
Flag Coverage Δ
rust 84.02% <87.17%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
flareon/src/error.rs 89.83% <100.00%> (ø)
flareon/src/request.rs 87.50% <100.00%> (+7.23%) ⬆️
flareon/src/response.rs 98.24% <95.45%> (-1.76%) ⬇️
flareon/src/test.rs 92.11% <18.18%> (-3.54%) ⬇️

Copy link
Contributor

@seqre seqre left a comment

Choose a reason for hiding this comment

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

LGTM

);
match &response.body().inner {
BodyInner::Fixed(fixed) => {
assert_eq!(fixed, "{\"hello\":\"world\"}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: in another place, we're using r#"{"hello":"world"}"# for that case. It would be nice to represent it in one way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair

*request.body_mut() = Body::fixed(json_data.clone());
request.headers_mut().insert(
http::header::CONTENT_TYPE,
http::HeaderValue::from_static("application/json"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use flareon::headers::JSON_CONTENT_TYPE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a good practice not to use any data used by production code in tests. This might be overdoing stuff (after all, it's just a well-known constant), but this prevents tests from passing when, for instance, the constant would be refactored and modified by a mistake.

@m4tx m4tx merged commit 479d162 into master Nov 27, 2024
23 of 25 checks passed
@m4tx m4tx deleted the json branch November 27, 2024 19:57
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