🎨 style: fix clippy warnings and clean up test code
This commit is contained in:
committed by
Jeremiah Russell
parent
084a643b74
commit
b26887e05a
@@ -3,19 +3,20 @@
|
||||
//! These tests focus on testing the individual components and methods of the Gmail client
|
||||
//! that can be tested without requiring actual Gmail API calls.
|
||||
|
||||
use cull_gmail::{GmailClient, ClientConfig};
|
||||
|
||||
/// Test module for Gmail client functionality
|
||||
mod gmail_client_tests {
|
||||
use cull_gmail::ClientConfig;
|
||||
|
||||
/// Test the default max results constant
|
||||
#[test]
|
||||
fn test_default_max_results() {
|
||||
let default_max = cull_gmail::DEFAULT_MAX_RESULTS;
|
||||
assert_eq!(default_max, "200");
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -25,57 +26,26 @@ mod gmail_client_tests {
|
||||
let default_max: u32 = cull_gmail::DEFAULT_MAX_RESULTS
|
||||
.parse()
|
||||
.expect("DEFAULT_MAX_RESULTS should be a valid u32");
|
||||
|
||||
|
||||
// Gmail API supports up to 500 results per page
|
||||
assert!(default_max > 0, "Max results should be positive");
|
||||
assert!(default_max <= 500, "Max results should not exceed Gmail API limit");
|
||||
assert!(default_max >= 10, "Max results should be reasonable for performance");
|
||||
assert!(
|
||||
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
|
||||
/// This test doesn't need actual Gmail authentication since Debug works on the struct fields
|
||||
/// Test that ClientConfig builder compiles and creates a config
|
||||
#[test]
|
||||
fn test_gmail_client_debug() {
|
||||
// We can't easily construct a GmailClient without authentication,
|
||||
// so we'll test the debug formatting indirectly by checking the implementation exists
|
||||
// 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")
|
||||
fn test_client_config_builder_works() {
|
||||
let _config = ClientConfig::builder()
|
||||
.with_client_id("test-id")
|
||||
.with_client_secret("test-secret")
|
||||
.build();
|
||||
|
||||
// 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");
|
||||
// Test passes if we reach here without panicking
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user