fix: preserve CLI log output and avoid incidental migrations

This commit is contained in:
objz committed 2026-10-01 23:01:12 +02:00
1 parent 7ea4860202
commit cf9007fa06
7 files changed
+114 -81

No files matched your search

+23
View File
@@ -1,6 +1,29 @@
// SPDX-FileCopyrightText: 2026 Constantin Bauer
// SPDX-License-Identifier: GPL-3.0-only
#[test]
fn following_log_bytes_keeps_partial_lines_and_handles_truncation() {
use super::read_new_log_bytes;
use std::io::Write;
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("latest.log");
std::fs::write(&path, b"abc").unwrap();
let mut offset = 0;
assert_eq!(read_new_log_bytes(&path, &mut offset).unwrap(), b"abc");
let mut file = std::fs::OpenOptions::new()
.append(true)
.open(&path)
.unwrap();
file.write_all(b"def\nnext\n").unwrap();
assert_eq!(
read_new_log_bytes(&path, &mut offset).unwrap(),
b"def\nnext\n"
);
assert!(read_new_log_bytes(&path, &mut offset).unwrap().is_empty());
std::fs::write(&path, b"new\n").unwrap();
assert_eq!(read_new_log_bytes(&path, &mut offset).unwrap(), b"new\n");
}
use super::resolve_log_path;
#[test]
+16
View File
@@ -44,3 +44,19 @@ fn formats_datetime_consistently() {
let dt = Utc.with_ymd_and_hms(2024, 1, 2, 3, 4, 5).unwrap();
assert_eq!(format_datetime(&dt), "2024-01-02 03:04:05 UTC");
}
#[test]
fn table_padding_uses_cells_for_wide_and_combining_names() {
let table = render_table(
&["Name", "State"],
&[
vec!["界界界".to_owned(), "first".to_owned()],
vec!["e\u{301}".to_owned(), "second".to_owned()],
],
);
let rows = table.lines().skip(2).collect::<Vec<_>>();
for row in rows {
let start = row.find(['f', 's']).unwrap();
assert_eq!(ratatui::text::Span::raw(&row[..start]).width(), 8);
}
}