-
Notifications
You must be signed in to change notification settings - Fork 2k
test(turborepo-analytics): improve unit test coverage #10651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add 3 new tests to increase coverage from 87.50% to 90.57%: - test_close_with_timeout: Tests the close_with_timeout method - test_client_error_handling: Tests error handling when client fails - test_add_session_id: Tests the add_session_id utility function These tests cover previously untested code paths including timeout handling, error scenarios, and utility functions.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
#[tokio::test] | ||
async fn test_close_with_timeout() { | ||
let (tx, _rx) = mpsc::unbounded_channel(); | ||
|
||
let client = DummyClient { | ||
events: Default::default(), | ||
tx, | ||
}; | ||
|
||
let (analytics_sender, analytics_handle) = start_analytics( | ||
APIAuth { | ||
token: "foo".to_string(), | ||
team_id: Some("bar".to_string()), | ||
team_slug: None, | ||
}, | ||
client.clone(), | ||
); | ||
|
||
// Send an event | ||
analytics_sender | ||
.send(AnalyticsEvent { | ||
session_id: None, | ||
source: CacheSource::Local, | ||
event: CacheEvent::Hit, | ||
hash: "".to_string(), | ||
duration: 0, | ||
}) | ||
.unwrap(); | ||
|
||
// Test close_with_timeout - should not panic | ||
analytics_handle.close_with_timeout().await; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop this test, I'm not sure what this tests that other ones don't already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
Co-authored-by: Chris Olszewski <chris.olszewski@vercel.com>
Summary
Improves test coverage for from 87.50% to 90.57% (+3.07%) in
turobrepo-analytics
.Changes
Added 3 new tests to cover previously untested code paths:
Coverage Impact
All tests pass and cover important error handling and utility function scenarios.