🎨 style: fix clippy warnings and clean up test code
This commit is contained in:
committed by
Jeremiah Russell
parent
084a643b74
commit
b26887e05a
@@ -227,7 +227,9 @@ mod tests {
|
|||||||
|
|
||||||
// Set up a realistic date and subject
|
// Set up a realistic date and subject
|
||||||
summary.set_date(Some("2023-12-25 10:30:00 GMT".to_string()));
|
summary.set_date(Some("2023-12-25 10:30:00 GMT".to_string()));
|
||||||
summary.set_subject(Some("This is a very long subject that should be elided".to_string()));
|
summary.set_subject(Some(
|
||||||
|
"This is a very long subject that should be elided".to_string(),
|
||||||
|
));
|
||||||
|
|
||||||
let display = summary.list_date_and_subject();
|
let display = summary.list_date_and_subject();
|
||||||
|
|
||||||
@@ -278,7 +280,7 @@ mod tests {
|
|||||||
summary.set_subject(Some("Debug Subject".to_string()));
|
summary.set_subject(Some("Debug Subject".to_string()));
|
||||||
summary.set_date(Some("2023-12-25".to_string()));
|
summary.set_date(Some("2023-12-25".to_string()));
|
||||||
|
|
||||||
let debug_str = format!("{:?}", summary);
|
let debug_str = format!("{summary:?}");
|
||||||
|
|
||||||
// Verify the debug output contains expected fields
|
// Verify the debug output contains expected fields
|
||||||
assert!(debug_str.contains("MessageSummary"));
|
assert!(debug_str.contains("MessageSummary"));
|
||||||
@@ -308,7 +310,10 @@ mod tests {
|
|||||||
let test_cases = vec![
|
let test_cases = vec![
|
||||||
("", "Empty ID"),
|
("", "Empty ID"),
|
||||||
("a", "Single char ID"),
|
("a", "Single char ID"),
|
||||||
("very_long_message_id_that_exceeds_normal_length_expectations_123456789", "Very long ID"),
|
(
|
||||||
|
"very_long_message_id_that_exceeds_normal_length_expectations_123456789",
|
||||||
|
"Very long ID",
|
||||||
|
),
|
||||||
("msg-with-dashes", "ID with dashes"),
|
("msg-with-dashes", "ID with dashes"),
|
||||||
("msg_with_underscores", "ID with underscores"),
|
("msg_with_underscores", "ID with underscores"),
|
||||||
("123456789", "Numeric ID"),
|
("123456789", "Numeric ID"),
|
||||||
@@ -316,7 +321,7 @@ mod tests {
|
|||||||
|
|
||||||
for (id, description) in test_cases {
|
for (id, description) in test_cases {
|
||||||
let summary = MessageSummary::new(id);
|
let summary = MessageSummary::new(id);
|
||||||
assert_eq!(summary.id(), id, "Failed for case: {}", description);
|
assert_eq!(summary.id(), id, "Failed for case: {description}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
//! These tests focus on testing the individual components and methods of the Gmail client
|
//! These tests focus on testing the individual components and methods of the Gmail client
|
||||||
//! that can be tested without requiring actual Gmail API calls.
|
//! that can be tested without requiring actual Gmail API calls.
|
||||||
|
|
||||||
use cull_gmail::{GmailClient, ClientConfig};
|
|
||||||
|
|
||||||
/// Test module for Gmail client functionality
|
/// Test module for Gmail client functionality
|
||||||
mod gmail_client_tests {
|
mod gmail_client_tests {
|
||||||
|
use cull_gmail::ClientConfig;
|
||||||
|
|
||||||
/// Test the default max results constant
|
/// Test the default max results constant
|
||||||
#[test]
|
#[test]
|
||||||
@@ -15,7 +14,9 @@ mod gmail_client_tests {
|
|||||||
assert_eq!(default_max, "200");
|
assert_eq!(default_max, "200");
|
||||||
|
|
||||||
// Verify it can be parsed as u32
|
// Verify it can be parsed as u32
|
||||||
let parsed: u32 = default_max.parse().expect("DEFAULT_MAX_RESULTS should be a valid u32");
|
let parsed: u32 = default_max
|
||||||
|
.parse()
|
||||||
|
.expect("DEFAULT_MAX_RESULTS should be a valid u32");
|
||||||
assert_eq!(parsed, 200);
|
assert_eq!(parsed, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,54 +29,23 @@ mod gmail_client_tests {
|
|||||||
|
|
||||||
// Gmail API supports up to 500 results per page
|
// Gmail API supports up to 500 results per page
|
||||||
assert!(default_max > 0, "Max results should be positive");
|
assert!(default_max > 0, "Max results should be positive");
|
||||||
assert!(default_max <= 500, "Max results should not exceed Gmail API limit");
|
assert!(
|
||||||
assert!(default_max >= 10, "Max results should be reasonable for performance");
|
default_max <= 500,
|
||||||
|
"Max results should not exceed Gmail API limit"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
default_max >= 10,
|
||||||
|
"Max results should be reasonable for performance"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test Debug implementation for GmailClient
|
/// Test that ClientConfig builder compiles and creates a config
|
||||||
/// This test doesn't need actual Gmail authentication since Debug works on the struct fields
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_gmail_client_debug() {
|
fn test_client_config_builder_works() {
|
||||||
// We can't easily construct a GmailClient without authentication,
|
let _config = ClientConfig::builder()
|
||||||
// so we'll test the debug formatting indirectly by checking the implementation exists
|
.with_client_id("test-id")
|
||||||
// and that it's properly named in the debug output structure.
|
|
||||||
|
|
||||||
// This test mainly ensures the Debug trait is properly implemented
|
|
||||||
// and doesn't panic or cause compilation issues
|
|
||||||
|
|
||||||
// Note: A full test would require mocking the Gmail authentication,
|
|
||||||
// which is complex and beyond the scope of unit tests
|
|
||||||
assert!(true, "Debug trait implementation compiles successfully");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Tests for public API constants and utilities
|
|
||||||
mod public_api_tests {
|
|
||||||
use cull_gmail::ClientConfig;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_client_config_builder_basic() {
|
|
||||||
// Test that ClientConfig builder works and creates valid configs
|
|
||||||
let config = ClientConfig::builder()
|
|
||||||
.with_client_id("test-client-id")
|
|
||||||
.with_client_secret("test-secret")
|
.with_client_secret("test-secret")
|
||||||
.build();
|
.build();
|
||||||
|
// Test passes if we reach here without panicking
|
||||||
// Basic validation that config was created successfully
|
|
||||||
// (We can't easily test the internal fields without making them public)
|
|
||||||
// This at least ensures the builder pattern compiles and doesn't panic
|
|
||||||
assert!(true, "ClientConfig builder works without panicking");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_client_config_builder_chain() {
|
|
||||||
// Test that builder methods can be chained
|
|
||||||
let _config = ClientConfig::builder()
|
|
||||||
.with_client_id("client")
|
|
||||||
.with_client_secret("secret")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// If we reach this point, the chaining worked
|
|
||||||
assert!(true, "Builder method chaining works");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user