- Added `RpcError` enum for comprehensive error handling in RPC operations. - Introduced `HealthReporter` and `HealthService` for managing service health statuses. - Implemented health check and watch functionality in the health service. - Created integration tests for health check service, covering various scenarios. - Added unit tests for client options validation and stream functionality. - Established logging infrastructure for terminal and registry components. - Implemented logging lifecycle management and conflict resolution in tests.
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
use buffa::Message;
|
|
use proto::control::TerminalInfos;
|
|
|
|
use crate::storage::{decode, load, save};
|
|
|
|
#[test]
|
|
fn corrupt_snapshot_is_preserved_and_uncommitted_temporary_is_ignored() {
|
|
let directory = tempfile::tempdir().unwrap();
|
|
let path = directory.path().join("terminals.bin");
|
|
std::fs::write(&path, [0xff]).unwrap();
|
|
assert!(load(&path).unwrap().infos.is_empty());
|
|
let backup = std::fs::read_dir(directory.path())
|
|
.unwrap()
|
|
.next()
|
|
.unwrap()
|
|
.unwrap()
|
|
.path();
|
|
assert!(
|
|
backup
|
|
.file_name()
|
|
.unwrap()
|
|
.to_string_lossy()
|
|
.contains(".corrupt-")
|
|
);
|
|
assert_eq!(std::fs::read(backup).unwrap(), [0xff]);
|
|
std::fs::write(
|
|
directory.path().join(".registry-snapshot-interrupted"),
|
|
[0xff],
|
|
)
|
|
.unwrap();
|
|
save(&path, TerminalInfos::default()).unwrap();
|
|
assert!(load(&path).unwrap().infos.is_empty());
|
|
assert_eq!(std::fs::read(path).unwrap(), Vec::<u8>::new());
|
|
}
|
|
|
|
#[test]
|
|
fn semantic_corruption_is_rejected() {
|
|
let snapshot = TerminalInfos {
|
|
infos: [("wrong-id".into(), Default::default())]
|
|
.into_iter()
|
|
.collect(),
|
|
..Default::default()
|
|
};
|
|
assert!(decode(&snapshot.try_encode_to_vec().unwrap()).is_err());
|
|
}
|