martin-g commented on code in PR #514:
URL: https://github.com/apache/avro-rs/pull/514#discussion_r2984234337


##########
avro_test_helper/src/logger.rs:
##########
@@ -53,13 +53,47 @@ fn test_logger() -> &'static TestLogger {
     })
 }
 
+/// Clears all log messages stored in the thread-local storage.
+///
+/// # Panics
+/// This function will panic if:
+/// - The thread-local `LOG_MESSAGES` is already borrowed and cannot
+///   be mutably borrowed.
+///
+/// The panic includes a debug representation of the error encountered.
 pub fn clear_log_messages() {
     LOG_MESSAGES.with(|msgs| match msgs.try_borrow_mut() {
         Ok(mut log_messages) => log_messages.clear(),
         Err(err) => panic!("Failed to clear log messages: {err:?}"),
     });
 }
 
+/// Asserts that a specific log message has not been logged.
+///
+/// This function checks the most recently logged message from a thread-local
+/// storage and ensures that it does not match the provided 
`unexpected_message`.
+/// If the message does match, the function will panic with an appropriate 
error
+/// message indicating the unexpected log entry.
+///
+/// # Arguments
+/// - `unexpected_message`: A string slice that represents the log message
+///   that is not expected to be logged. If this message matches the last
+///   logged message, the function will panic.
+///
+/// # Panics
+/// - This function will panic if the `unexpected_message` matches the most
+///   recently logged message.
+///
+/// # Example
+/// ```ignore
+/// // Assume LOG_MESSAGES is set up to capture log messages.
+/// log_message("Unexpected Error");
+/// assert_not_logged("Unexpected Error");
+/// // This will panic with the message:
+/// // "The following log message should not have been logged: 'Unexpected 
Error'"
+///
+/// assert_not_logged("Non-existent Message");
+/// // This will pass without issue since the message was not logged.

Review Comment:
   It could be improved to check in all!
   It was not needed to behave like that so far.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to