mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 11:06:17 +00:00
test: add insta snapshot test for storage error display format Add snapshot test to detect unexpected changes in StorageError display format. This catches output format regressions that traditional assert tests might miss. Refs #740
This commit is contained in:
@@ -145,6 +145,7 @@ serial_test = { workspace = true }
|
||||
opentelemetry_sdk = { workspace = true }
|
||||
proptest = "1"
|
||||
rcgen.workspace = true
|
||||
insta = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
shadow-rs = { workspace = true, features = ["build", "metadata"] }
|
||||
|
||||
@@ -1448,4 +1448,34 @@ mod tests {
|
||||
assert_eq!(original_error, recovered_error);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_storage_error_display_snapshot() {
|
||||
// Snapshot test to detect unexpected changes in error display format
|
||||
let errors = vec![
|
||||
StorageError::BucketNotFound("test-bucket".to_string()),
|
||||
StorageError::ObjectNotFound("bucket".to_string(), "object".to_string()),
|
||||
StorageError::VersionNotFound("bucket".to_string(), "object".to_string(), "v1".to_string()),
|
||||
StorageError::InvalidUploadID("bucket".to_string(), "object".to_string(), "upload123".to_string()),
|
||||
StorageError::DiskFull,
|
||||
StorageError::FaultyDisk,
|
||||
StorageError::FileNotFound,
|
||||
StorageError::VolumeNotFound,
|
||||
StorageError::ErasureReadQuorum,
|
||||
StorageError::ErasureWriteQuorum,
|
||||
StorageError::DecommissionAlreadyRunning,
|
||||
StorageError::RebalanceAlreadyRunning,
|
||||
StorageError::OperationCanceled,
|
||||
StorageError::NamespaceLockQuorumUnavailable {
|
||||
mode: "write",
|
||||
bucket: "bucket".into(),
|
||||
object: "object".into(),
|
||||
required: 3,
|
||||
achieved: 2,
|
||||
},
|
||||
];
|
||||
|
||||
let error_messages: Vec<String> = errors.iter().map(|e| e.to_string()).collect();
|
||||
insta::assert_yaml_snapshot!("storage_error_display", error_messages);
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: crates/ecstore/src/error/mod.rs
|
||||
expression: error_messages
|
||||
---
|
||||
- "Bucket not found: test-bucket"
|
||||
- "Object not found: bucket/object"
|
||||
- "Version not found: bucket/object-v1"
|
||||
- "Invalid upload id: bucket/object-upload123"
|
||||
- Disk full
|
||||
- Faulty disk
|
||||
- File not found
|
||||
- Volume not found
|
||||
- erasure read quorum
|
||||
- erasure write quorum
|
||||
- Decommission already running
|
||||
- Rebalance already running
|
||||
- Operation canceled
|
||||
- "Namespace lock quorum unavailable for write lock on bucket/object: required 3, achieved 2"
|
||||
Reference in New Issue
Block a user