Skip to content

Commit

Permalink
fix fmt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TuEmb committed Jul 12, 2024
1 parent 9b2c6df commit c98af23
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions src/append/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,32 @@ mod test {
let current_time = Local::now().format("%Y-%m-%d").to_string();
let tempdir = tempfile::tempdir().unwrap();
let builder = FileAppender::builder()
.build(tempdir.path().join("foo").join("bar").join("logs/log-$TIME{%Y-%m-%d}.log"))
.unwrap();
let expected_path = tempdir.path().join(format!("foo/bar/logs/log-{}.log", current_time));
.build(
tempdir
.path()
.join("foo")
.join("bar")
.join("logs/log-$TIME{%Y-%m-%d}.log"),
)
.unwrap();
let expected_path = tempdir
.path()
.join(format!("foo/bar/logs/log-{}.log", current_time));
assert_eq!(builder.path, expected_path);
}

#[test]
fn test_date_time_format_with_invalid_format() {
let tempdir = tempfile::tempdir().unwrap();
let builder = FileAppender::builder()
.build(tempdir.path().join("foo").join("bar").join("logs/log-$TIME{INVALID}.log"))
.unwrap();
.build(
tempdir
.path()
.join("foo")
.join("bar")
.join("logs/log-$TIME{INVALID}.log"),
)
.unwrap();
let expected_path = tempdir.path().join("foo/bar/logs/log-INVALID.log");
assert_eq!(builder.path, expected_path);
}
Expand All @@ -244,8 +258,8 @@ mod test {
fn test_date_time_format_without_placeholder() {
let tempdir = tempfile::tempdir().unwrap();
let builder = FileAppender::builder()
.build(tempdir.path().join("foo").join("bar").join("bar.log"))
.unwrap();
.build(tempdir.path().join("foo").join("bar").join("bar.log"))
.unwrap();
let expected_path = tempdir.path().join("foo/bar/bar.log");
assert_eq!(builder.path, expected_path);
}
Expand All @@ -255,9 +269,18 @@ mod test {
let current_time = Local::now().format("%Y-%m-%d").to_string();
let tempdir = tempfile::tempdir().unwrap();
let builder = FileAppender::builder()
.build(tempdir.path().join("foo").join("bar").join("logs-$TIME{%Y-%m-%d}/log-$TIME{%Y-%m-%d}.log"))
.unwrap();
let expected_path = tempdir.path().join(format!("foo/bar/logs-{}/log-{}.log", current_time, current_time));
.build(
tempdir
.path()
.join("foo")
.join("bar")
.join("logs-$TIME{%Y-%m-%d}/log-$TIME{%Y-%m-%d}.log"),
)
.unwrap();
let expected_path = tempdir.path().join(format!(
"foo/bar/logs-{}/log-{}.log",
current_time, current_time
));
assert_eq!(builder.path, expected_path);
}
}

0 comments on commit c98af23

Please sign in to comment.