mirror of https://github.com/fafhrd91/actix-web
Fix a few errors with time related tests from the `time` upgrade
This commit is contained in:
parent
bd4807f4d3
commit
52018a6c47
|
@ -992,7 +992,7 @@ impl<'a, 'b> PartialEq<Cookie<'b>> for Cookie<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{Cookie, SameSite};
|
use super::{Cookie, SameSite};
|
||||||
use time::{OffsetDateTime, PrimitiveDateTime, UtcOffset};
|
use time::{PrimitiveDateTime, UtcOffset};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn format() {
|
fn format() {
|
||||||
|
|
|
@ -216,7 +216,7 @@ where
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{Cookie, SameSite};
|
use super::{Cookie, SameSite};
|
||||||
use time::{Duration, OffsetDateTime, PrimitiveDateTime, UtcOffset};
|
use time::{Duration, PrimitiveDateTime, UtcOffset};
|
||||||
|
|
||||||
macro_rules! assert_eq_parse {
|
macro_rules! assert_eq_parse {
|
||||||
($string:expr, $expected:expr) => {
|
($string:expr, $expected:expr) => {
|
||||||
|
|
|
@ -74,28 +74,28 @@ impl From<HttpDate> for SystemTime {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::HttpDate;
|
use super::HttpDate;
|
||||||
use time::{OffsetDateTime, Date, Time};
|
use time::{PrimitiveDateTime, Date, Time, UtcOffset};
|
||||||
|
|
||||||
const NOV_07: HttpDate = HttpDate(OffsetDateTime::new(
|
|
||||||
Date::try_from_ymd(1994, 11, 7).unwrap(),
|
|
||||||
Time::try_from_hms(8, 48, 37).unwrap()
|
|
||||||
));
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date() {
|
fn test_date() {
|
||||||
|
let nov_07 = HttpDate(PrimitiveDateTime::new(
|
||||||
|
Date::try_from_ymd(1994, 11, 7).unwrap(),
|
||||||
|
Time::try_from_hms(8, 48, 37).unwrap()
|
||||||
|
).using_offset(UtcOffset::UTC));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"Sun, 07 Nov 1994 08:48:37 GMT".parse::<HttpDate>().unwrap(),
|
"Sun, 07 Nov 1994 08:48:37 GMT".parse::<HttpDate>().unwrap(),
|
||||||
NOV_07
|
nov_07
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"Sunday, 07-Nov-94 08:48:37 GMT"
|
"Sunday, 07-Nov-94 08:48:37 GMT"
|
||||||
.parse::<HttpDate>()
|
.parse::<HttpDate>()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
NOV_07
|
nov_07
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"Sun Nov 7 08:48:37 1994".parse::<HttpDate>().unwrap(),
|
"Sun Nov 7 08:48:37 1994".parse::<HttpDate>().unwrap(),
|
||||||
NOV_07
|
nov_07
|
||||||
);
|
);
|
||||||
assert!("this-is-no-date".parse::<HttpDate>().is_err());
|
assert!("this-is-no-date".parse::<HttpDate>().is_err());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue