Skip to content

Commit 8de4ecb

Browse files
committed
test(credential): Verify existing serde behavior for NotSupported
1 parent de77d20 commit 8de4ecb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

credential/cargo-credential/src/error.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,19 @@ mod tests {
186186
use super::Error;
187187

188188
#[test]
189-
pub fn unknown_kind() {
189+
fn not_supported_roundtrip() {
190+
let input = Error::UrlNotSupported;
191+
192+
let expected_json = r#"{"kind":"url-not-supported"}"#;
193+
let actual_json = serde_json::to_string(&input).unwrap();
194+
assert_eq!(actual_json, expected_json);
195+
196+
let actual = serde_json::from_str(&actual_json).unwrap();
197+
assert!(matches!(actual, Error::UrlNotSupported));
198+
}
199+
200+
#[test]
201+
fn deserialize_to_unknown_kind() {
190202
let json = r#"{
191203
"kind": "unexpected-kind",
192204
"unexpected-content": "test"
@@ -196,7 +208,7 @@ mod tests {
196208
}
197209

198210
#[test]
199-
pub fn roundtrip() {
211+
fn other_roundtrip() {
200212
// Construct an error with context
201213
let e = anyhow::anyhow!("E1").context("E2").context("E3");
202214
// Convert to a string with contexts.

0 commit comments

Comments
 (0)