[test] Check content of error message#2582
Closed
szabgab wants to merge 1 commit intorust-lang:masterfrom
Closed
Conversation
in failure_on_missing_theme_directory
Rabbival
reviewed
Apr 1, 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"); |
There was a problem hiding this comment.
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); }
}
Contributor
|
I'm going to close as superseded by #2676, which is able to validate the entire output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
in failure_on_missing_theme_directory