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

Added unit tests for format #3606

Merged
merged 3 commits into from
Jan 20, 2025
Merged

Conversation

ashishajr
Copy link
Contributor

Description

Added unit tests for hurl::runner::filter::format

Related Issue

Add unit tests on hurl::runner::filter

@lepapareil
Copy link
Collaborator

/rebase

@hurl-bot
Copy link
Collaborator

🕗 /rebase is running, please wait for completion.

@hurl-bot
Copy link
Collaborator

🔨 Auto rebase from Orange-OpenSource/hurl/master succeeds, ashishajr/hurl/filter-format now embeds these commits:

@jcamiel jcamiel marked this pull request as ready for review January 20, 2025 09:38
Copy link
Collaborator

@jcamiel jcamiel left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @ashishajr . We should add another test unit when the format specifier is not valid for instance format "%%%". The code is panicking with this input so the new test should be marked with #[should_panic].

I'm creating a new bug issue so we'll fix this panic! and have a good error message.

packages/hurl/src/runner/filter/format.rs Outdated Show resolved Hide resolved
packages/hurl/src/runner/filter/format.rs Outdated Show resolved Hide resolved
jcamiel
jcamiel previously approved these changes Jan 20, 2025
Copy link
Collaborator

@jcamiel jcamiel left a comment

Choose a reason for hiding this comment

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

Looks good thanks @ashishajr !

@ashishajr
Copy link
Contributor Author

Thanks for all the help @jcamiel :)

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 20, 2025

/rebase

@hurl-bot
Copy link
Collaborator

🕗 /rebase is running, please wait for completion.

@hurl-bot
Copy link
Collaborator

🔨 Auto rebase from Orange-OpenSource/hurl/master succeeds, ashishajr/hurl/filter-format now embeds these commits:

  • 0a6ee2f Added unit tests for decode
  • cc30851 Update crates
  • 198f72c Add variables to header_option integration test

@ashishajr
Copy link
Contributor Author

@jcamiel, could you please hold off on accepting this PR, I made a mistake, the newest test is panicking for the wrong reason.

It's panicking because I'm calling unwrap on the Err instead of panicking because of invalid format. I'm incorrectly passing String instead of Date

fn eval_filter_format_ko_invalid_format() {
    let variables = VariableSet::new();

    let filter = new_format_filter("%%");
    eval_filter(
        &filter,
        &Value::String("01/01/2025".to_string()), // <- Should be Value::Date
        &variables,
        false,
    )
    .unwrap(); // <- Test is panicking here
}

My apologies, let me quickly fix this

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 20, 2025

No worries, good catch!

@ashishajr
Copy link
Contributor Author

Should be fixed now!

@ashishajr ashishajr requested a review from jcamiel January 20, 2025 14:07
@jcamiel
Copy link
Collaborator

jcamiel commented Jan 20, 2025

/rebase

@hurl-bot
Copy link
Collaborator

🕗 /rebase is running, please wait for completion.

@hurl-bot
Copy link
Collaborator

🔨 Auto rebase from Orange-OpenSource/hurl/master succeeds, ashishajr/hurl/filter-format now embeds these commits:

  • be6fbf9 Remove hex-literal crate dependency

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 20, 2025

/accept

@hurl-bot
Copy link
Collaborator

🕗 /accept is running, please wait for completion.

@hurl-bot
Copy link
Collaborator

✅ Pull request merged with fast forward by jcamiel..

# List of commits merged from ashishajr/hurl/filter-format branch into Orange-OpenSource/hurl/master branch:

  • 96b80af Fixed incorrect panic unit test
  • baddf60 Added panic unit test for format
  • a9de5f6 Added unit tests for format

@hurl-bot hurl-bot merged commit 96b80af into Orange-OpenSource:master Jan 20, 2025
24 checks passed
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.

4 participants