-
Notifications
You must be signed in to change notification settings - Fork 1
feat(events): add TimeoutKind to classify Error::Timeout by operation #55
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
Open
devin-ai-integration
wants to merge
4
commits into
main
Choose a base branch
from
devin/1776970193-timeout-kind
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b5a3689
feat(events): add TimeoutKind to classify Error::Timeout by operation
devin-ai-integration[bot] 758905f
fix(events): use TimeoutKind::ServerConfig for server-config waiters
devin-ai-integration[bot] 145012a
test: adapt sdk_error_code test to Error::Timeout struct variant
devin-ai-integration[bot] 5aa07e3
style: apply rustfmt to sdk_error_code_tests Timeout adaptation
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| //! Integration tests for the typed timeout classification on | ||
| //! [`teamtalk::events::Error::Timeout`]. | ||
|
|
||
| use teamtalk::events::{Error, FfiError, TimeoutKind}; | ||
|
|
||
| #[test] | ||
| fn timeout_constructor_produces_timeout_variant() { | ||
| let err = Error::timeout(TimeoutKind::Command); | ||
| assert!(matches!( | ||
| err, | ||
| Error::Timeout { | ||
| kind: TimeoutKind::Command | ||
| } | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn timeout_kind_accessor_returns_kind_for_timeout() { | ||
| let kinds = [ | ||
| TimeoutKind::Command, | ||
| TimeoutKind::Connect, | ||
| TimeoutKind::Login, | ||
| TimeoutKind::Join, | ||
| TimeoutKind::Transfer, | ||
| TimeoutKind::ServerConfig, | ||
| TimeoutKind::Other, | ||
| ]; | ||
| for kind in kinds { | ||
| let err = Error::timeout(kind); | ||
| assert_eq!(err.timeout_kind(), Some(kind)); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn timeout_kind_accessor_returns_none_for_non_timeout_errors() { | ||
| assert!(Error::InitFailed.timeout_kind().is_none()); | ||
| assert!(Error::ConnectFailed.timeout_kind().is_none()); | ||
| assert!(Error::AuthFailed.timeout_kind().is_none()); | ||
| assert!(Error::InvalidParam.timeout_kind().is_none()); | ||
| assert!(Error::MissingLoginParams.timeout_kind().is_none()); | ||
| assert!(Error::MissingReconnectParams.timeout_kind().is_none()); | ||
| assert!( | ||
| Error::IoError { | ||
| message: "x".into(), | ||
| } | ||
| .timeout_kind() | ||
| .is_none() | ||
| ); | ||
| assert!( | ||
| Error::CommandFailed { | ||
| code: 1001, | ||
| message: "x".into(), | ||
| } | ||
| .timeout_kind() | ||
| .is_none() | ||
| ); | ||
| assert!( | ||
| Error::ClientError { | ||
| code: 10000, | ||
| message: "x".into(), | ||
| } | ||
| .timeout_kind() | ||
| .is_none() | ||
| ); | ||
| assert!(Error::Ffi(FfiError::NullPointer).timeout_kind().is_none()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn display_includes_kind_name() { | ||
| let msg = format!("{}", Error::timeout(TimeoutKind::Login)); | ||
| assert!( | ||
| msg.contains("login"), | ||
| "Timeout Display should include kind name, got: {msg}" | ||
| ); | ||
| assert!( | ||
| msg.contains("timed out"), | ||
| "Timeout Display should include the base phrase, got: {msg}" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn display_distinguishes_each_kind() { | ||
| let login = format!("{}", Error::timeout(TimeoutKind::Login)); | ||
| let transfer = format!("{}", Error::timeout(TimeoutKind::Transfer)); | ||
| assert_ne!(login, transfer); | ||
| } | ||
|
|
||
| #[test] | ||
| fn timeout_kind_name_is_snake_case_stable() { | ||
| assert_eq!(TimeoutKind::Command.name(), "command"); | ||
| assert_eq!(TimeoutKind::Connect.name(), "connect"); | ||
| assert_eq!(TimeoutKind::Login.name(), "login"); | ||
| assert_eq!(TimeoutKind::Join.name(), "join"); | ||
| assert_eq!(TimeoutKind::Transfer.name(), "transfer"); | ||
| assert_eq!(TimeoutKind::ServerConfig.name(), "server_config"); | ||
| assert_eq!(TimeoutKind::Other.name(), "other"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn timeout_kind_display_matches_name() { | ||
| let all = [ | ||
| TimeoutKind::Command, | ||
| TimeoutKind::Connect, | ||
| TimeoutKind::Login, | ||
| TimeoutKind::Join, | ||
| TimeoutKind::Transfer, | ||
| TimeoutKind::ServerConfig, | ||
| TimeoutKind::Other, | ||
| ]; | ||
| for kind in all { | ||
| assert_eq!(format!("{kind}"), kind.name()); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn names_are_unique() { | ||
| let all = [ | ||
| TimeoutKind::Command, | ||
| TimeoutKind::Connect, | ||
| TimeoutKind::Login, | ||
| TimeoutKind::Join, | ||
| TimeoutKind::Transfer, | ||
| TimeoutKind::ServerConfig, | ||
| TimeoutKind::Other, | ||
| ]; | ||
| let mut names: Vec<_> = all.iter().map(|k| k.name()).collect(); | ||
| names.sort_unstable(); | ||
| let len = names.len(); | ||
| names.dedup(); | ||
| assert_eq!(len, names.len(), "TimeoutKind names must be unique"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn derives_are_available() { | ||
| // Compile-time assertions that the derived traits exist. | ||
| fn assert_impls<T: Copy + Clone + std::fmt::Debug + Eq + std::hash::Hash>() {} | ||
| assert_impls::<TimeoutKind>(); | ||
|
|
||
| // Equality and hash work. | ||
| let a = TimeoutKind::Command; | ||
| let b = TimeoutKind::Command; | ||
| let c = TimeoutKind::Login; | ||
| assert_eq!(a, b); | ||
| assert_ne!(a, c); | ||
| let mut set = std::collections::HashSet::new(); | ||
| set.insert(a); | ||
| set.insert(b); | ||
| set.insert(c); | ||
| assert_eq!(set.len(), 2); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.