mirror of
https://github.com/veeso/termscp.git
synced 2026-04-10 12:12:06 -07:00
Fixed time check tests
This commit is contained in:
@@ -705,6 +705,7 @@ impl FileTransfer for FtpFileTransfer {
|
|||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::utils::fmt::fmt_time;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -778,25 +779,16 @@ mod tests {
|
|||||||
assert_eq!(file.group, Some(9));
|
assert_eq!(file.group, Some(9));
|
||||||
assert_eq!(file.unix_pex.unwrap(), (7, 5, 5));
|
assert_eq!(file.unix_pex.unwrap(), (7, 5, 5));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
file.last_access_time
|
fmt_time(file.last_access_time, "%m %d %M").as_str(),
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
"11 05 32"
|
||||||
.ok()
|
|
||||||
.unwrap(),
|
|
||||||
Duration::from_secs(1604593920)
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
file.last_change_time
|
fmt_time(file.last_change_time, "%m %d %M").as_str(),
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
"11 05 32"
|
||||||
.ok()
|
|
||||||
.unwrap(),
|
|
||||||
Duration::from_secs(1604593920)
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
file.creation_time
|
fmt_time(file.creation_time, "%m %d %M").as_str(),
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
"11 05 32"
|
||||||
.ok()
|
|
||||||
.unwrap(),
|
|
||||||
Duration::from_secs(1604593920)
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
panic!("Expected file, got directory");
|
panic!("Expected file, got directory");
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ pub fn parse_datetime(tm: &str, fmt: &str) -> Result<SystemTime, ParseError> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::utils::fmt::fmt_time;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_utils_parse_remote_opt() {
|
fn test_utils_parse_remote_opt() {
|
||||||
@@ -294,22 +295,24 @@ mod tests {
|
|||||||
fn test_utils_parse_lstime() {
|
fn test_utils_parse_lstime() {
|
||||||
// Good cases
|
// Good cases
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_lstime("Nov 5 16:32", "%b %d %Y", "%b %d %H:%M")
|
fmt_time(
|
||||||
.ok()
|
parse_lstime("Nov 5 16:32", "%b %d %Y", "%b %d %H:%M")
|
||||||
.unwrap()
|
.ok()
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
.unwrap(),
|
||||||
.ok()
|
"%m %d %M"
|
||||||
.unwrap(),
|
)
|
||||||
Duration::from_secs(1604593920)
|
.as_str(),
|
||||||
|
"11 05 32"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_lstime("Dec 2 21:32", "%b %d %Y", "%b %d %H:%M")
|
fmt_time(
|
||||||
.ok()
|
parse_lstime("Dec 2 21:32", "%b %d %Y", "%b %d %H:%M")
|
||||||
.unwrap()
|
.ok()
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
.unwrap(),
|
||||||
.ok()
|
"%m %d %M"
|
||||||
.unwrap(),
|
)
|
||||||
Duration::from_secs(1606944720)
|
.as_str(),
|
||||||
|
"12 02 32"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_lstime("Nov 5 2018", "%b %d %Y", "%b %d %H:%M")
|
parse_lstime("Nov 5 2018", "%b %d %Y", "%b %d %H:%M")
|
||||||
|
|||||||
Reference in New Issue
Block a user