Skip to content

[test] Check content of error message#2582

Closed
szabgab wants to merge 1 commit intorust-lang:masterfrom
szabgab:test/failure_on_missing_theme_directory
Closed

[test] Check content of error message#2582
szabgab wants to merge 1 commit intorust-lang:masterfrom
szabgab:test/failure_on_missing_theme_directory

Conversation

@szabgab
Copy link
Contributor

@szabgab szabgab commented Mar 9, 2025

in failure_on_missing_theme_directory

in failure_on_missing_theme_directory
@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Mar 9, 2025
Comment on lines 734 to +736
assert!(got.is_err());
let error_message = got.err().unwrap().to_string();
assert_eq!(error_message, "Rendering failed");
Copy link

Choose a reason for hiding this comment

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

I do find it a little offsetting that you check the string literal within the message, meaning that if someone happens to change a single char there in the future the test would fail.
Also, and that one is more of a matter of personal taste, you might get a more informative test (and a slightly cleaner one) if you wrote it like:

match got{
    Err(e) => { assert_eq1(e.to_string(), "Rendering failed"); },
    Ok(content) => { panic!("Expected an error but got an Ok with content: {:?}", content); }
}

@ehuss
Copy link
Contributor

ehuss commented Apr 23, 2025

I'm going to close as superseded by #2676, which is able to validate the entire output.

@ehuss ehuss closed this Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments