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

chore: improve test coverage in cli config #2313

Conversation

laststylebender14
Copy link
Contributor

Summary:
Briefly describe the changes made in this PR.

Issue Reference(s):
Fixes #... (Replace "..." with the issue number)

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

@laststylebender14 laststylebender14 marked this pull request as draft June 30, 2024 16:33
@github-actions github-actions bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label Jun 30, 2024
@laststylebender14 laststylebender14 changed the title Chore/improve test coverage in cli config chore: improve test coverage in cli config Jun 30, 2024
@laststylebender14 laststylebender14 marked this pull request as ready for review July 1, 2024 05:41
) -> Self {
Self { merge_type, consolidate_url, tree_shake, use_better_names }
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if I will ever use this API if the default operator exists. It more comfortable to use default().merge_type(1).consolidate_url(0.5) etc. Than using Preset::new(1, 0.5) and then have to forcefully pass the others parameters. Also it's easy to make a mistake of swapping the intended values of merge_type with consolidate_url since both are f32.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, agreed changed to use setters.

let original_url: Url = "https://tailcall.run".parse().unwrap();
let original_request = reqwest::Request::new(reqwest::Method::GET, original_url.clone());
let resource: Resource = original_request.try_clone().unwrap().into();
if let Resource::Request(converted_req) = resource {
Copy link
Contributor

Choose a reason for hiding this comment

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

No if conditions in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

umm, if we want to verify the variants of enums then we can either use match and if.
there's another way to verify this via external crate assert_matches!. will something like following work?

  assert_matches!(
        resource,
        Resource::Request(req) if {
            req.url().as_str() == original_url.as_str() &&
            req.method() == Method::GET
        }
    );

@tusharmath tusharmath merged commit 0d822ac into feat/add-support-for-headers-in-request Jul 1, 2024
6 checks passed
@tusharmath tusharmath deleted the chore/improve-test-coverage-in-cli-config branch July 1, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore Routine tasks like conversions, reorganization, and maintenance work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants