Skip to content

Commit 6d8df9c

Browse files
author
zeroed
committed
Add a test to cover the TryInto<StatusCode> implementation
1 parent bcc630e commit 6d8df9c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/status.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,21 @@ pub(crate) mod private {
123123
impl<T, E> Sealed for Result<T, E> {}
124124
impl<T> Sealed for Option<T> {}
125125
}
126+
127+
#[cfg(test)]
128+
mod test {
129+
use super::Status;
130+
131+
#[test]
132+
fn construct_shorthand_with_valid_status_code() {
133+
let _res = Some(()).status(200).unwrap();
134+
}
135+
136+
#[test]
137+
#[should_panic(expected = "Could not convert into a valid `StatusCode`")]
138+
fn construct_shorthand_with_invalid_status_code() {
139+
let res: Result<(), std::io::Error> =
140+
Err(std::io::Error::new(std::io::ErrorKind::Other, "oh no!"));
141+
let _res = res.status(600).unwrap();
142+
}
143+
}

0 commit comments

Comments
 (0)