Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3500478
D4425.id14084.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D4425.id14084.diff
View Options
diff --git a/services/commtest/Cargo.lock b/services/commtest/Cargo.lock
--- a/services/commtest/Cargo.lock
+++ b/services/commtest/Cargo.lock
@@ -93,6 +93,7 @@
"bytesize",
"derive_more",
"futures",
+ "lazy_static",
"prost",
"tokio",
"tonic",
diff --git a/services/commtest/Cargo.toml b/services/commtest/Cargo.toml
--- a/services/commtest/Cargo.toml
+++ b/services/commtest/Cargo.toml
@@ -11,6 +11,7 @@
async-stream = "0.3.2"
derive_more = "0.99.16"
bytesize = "1.1.0"
+lazy_static = "1.4.0"
[build-dependencies]
tonic-build = "0.6"
diff --git a/services/commtest/tests/backup_test.rs b/services/commtest/tests/backup_test.rs
--- a/services/commtest/tests/backup_test.rs
+++ b/services/commtest/tests/backup_test.rs
@@ -47,7 +47,7 @@
Item::new(
String::new(),
vec![
- tools::get_dynamo_db_item_size_limit()
+ *tools::DYNAMO_DB_ITEM_SIZE_LIMIT
- ByteSize::b(attachments_fill_size / 2).as_u64() as usize,
],
vec!["holder0".to_string(), "holder1".to_string()],
@@ -62,8 +62,8 @@
Item::new(
String::new(),
vec![
- tools::get_grpc_chunk_size_limit(),
- tools::get_grpc_chunk_size_limit(),
+ *tools::GRPC_CHUNK_SIZE_LIMIT,
+ *tools::GRPC_CHUNK_SIZE_LIMIT,
],
vec![
"holder0".to_string(),
diff --git a/services/commtest/tests/blob_test.rs b/services/commtest/tests/blob_test.rs
--- a/services/commtest/tests/blob_test.rs
+++ b/services/commtest/tests/blob_test.rs
@@ -36,8 +36,8 @@
holder: "test_holder002".to_string(),
hash: "test_hash002".to_string(),
chunks_sizes: vec![
- tools::get_grpc_chunk_size_limit(),
- tools::get_grpc_chunk_size_limit(),
+ *tools::GRPC_CHUNK_SIZE_LIMIT,
+ *tools::GRPC_CHUNK_SIZE_LIMIT,
ByteSize::b(10).as_u64() as usize,
],
},
@@ -45,9 +45,9 @@
holder: "test_holder003".to_string(),
hash: "test_hash003".to_string(),
chunks_sizes: vec![
- tools::get_grpc_chunk_size_limit(),
+ *tools::GRPC_CHUNK_SIZE_LIMIT,
ByteSize::b(100).as_u64() as usize,
- tools::get_grpc_chunk_size_limit(),
+ *tools::GRPC_CHUNK_SIZE_LIMIT,
],
},
];
diff --git a/services/commtest/tests/lib/tools.rs b/services/commtest/tests/lib/tools.rs
--- a/services/commtest/tests/lib/tools.rs
+++ b/services/commtest/tests/lib/tools.rs
@@ -1,4 +1,5 @@
use bytesize::ByteSize;
+use lazy_static::lazy_static;
#[allow(dead_code)]
pub fn generate_nbytes(
@@ -21,16 +22,11 @@
TonicStatus(tonic::Status),
}
-#[allow(dead_code)]
-pub fn get_dynamo_db_item_size_limit() -> usize {
- ByteSize::kib(400).as_u64() as usize
-}
-
pub const GRPC_METADATA_SIZE_BYTES: usize = 5;
-#[allow(dead_code)]
-pub fn get_grpc_chunk_size_limit() -> usize {
- (ByteSize::mib(4).as_u64() as usize) - GRPC_METADATA_SIZE_BYTES
+lazy_static! {
+ pub static ref DYNAMO_DB_ITEM_SIZE_LIMIT: usize = ByteSize::kib(400).as_u64() as usize;
+ pub static ref GRPC_CHUNK_SIZE_LIMIT: usize = (ByteSize::mib(4).as_u64() as usize) - GRPC_METADATA_SIZE_BYTES;
}
#[allow(dead_code)]
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 1:42 AM (4 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2684508
Default Alt Text
D4425.id14084.diff (3 KB)
Attached To
Mode
D4425: [services] Tests - Use lazy static instead of functions
Attached
Detach File
Event Timeline
Log In to Comment