Skip to content

Commit 759451a

Browse files
committed
fix: update shard tests and suppress false dead code warnings
- Fix shard tests to use String for node_uid (matches API response) - Update mock data in shard_tests.rs (node_uid: 1 -> "1") - Update test assertions to compare with strings - Add #[allow(dead_code)] to status.rs structs/functions (they are used via main.rs routing but clippy doesn't detect it) All tests now pass: - cargo test --lib --all-features ✓ - cargo test --test '*' --all-features ✓ - cargo clippy --all-targets --all-features ✓ - cargo fmt --all -- --check ✓
1 parent 0672238 commit 759451a

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

crates/redis-enterprise/tests/shard_tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn master_shard() -> serde_json::Value {
1414
json!({
1515
"uid": "shard:1:1",
1616
"bdb_uid": 1,
17-
"node_uid": 1,
17+
"node_uid": "1",
1818
"role": "master",
1919
"status": "active",
2020
"slots": "0-8191",
@@ -28,7 +28,7 @@ fn replica_shard() -> serde_json::Value {
2828
json!({
2929
"uid": "shard:1:2",
3030
"bdb_uid": 1,
31-
"node_uid": 2,
31+
"node_uid": "2",
3232
"role": "slave",
3333
"status": "active",
3434
"slots": "0-8191",
@@ -40,7 +40,7 @@ fn backup_shard() -> serde_json::Value {
4040
json!({
4141
"uid": "shard:2:1",
4242
"bdb_uid": 2,
43-
"node_uid": 1,
43+
"node_uid": "1",
4444
"role": "master",
4545
"status": "backing-up",
4646
"slots": "8192-16383",
@@ -53,7 +53,7 @@ fn importing_shard() -> serde_json::Value {
5353
json!({
5454
"uid": "shard:3:1",
5555
"bdb_uid": 3,
56-
"node_uid": 3,
56+
"node_uid": "3",
5757
"role": "master",
5858
"status": "importing",
5959
"slots": "0-16383",
@@ -66,7 +66,7 @@ fn minimal_shard() -> serde_json::Value {
6666
json!({
6767
"uid": "shard:4:1",
6868
"bdb_uid": 4,
69-
"node_uid": 1,
69+
"node_uid": "1",
7070
"role": "master",
7171
"status": "active"
7272
})
@@ -132,7 +132,7 @@ async fn test_shard_list() {
132132
let master = &shards[0];
133133
assert_eq!(master.uid, "shard:1:1");
134134
assert_eq!(master.bdb_uid, 1);
135-
assert_eq!(master.node_uid, 1);
135+
assert_eq!(master.node_uid, "1");
136136
assert_eq!(master.role, "master");
137137
assert_eq!(master.status, "active");
138138
assert_eq!(master.slots, Some("0-8191".to_string()));
@@ -219,7 +219,7 @@ async fn test_shard_get() {
219219
let shard = result.unwrap();
220220
assert_eq!(shard.uid, "shard:1:1");
221221
assert_eq!(shard.bdb_uid, 1);
222-
assert_eq!(shard.node_uid, 1);
222+
assert_eq!(shard.node_uid, "1");
223223
assert_eq!(shard.role, "master");
224224
assert_eq!(shard.status, "active");
225225
assert_eq!(shard.slots, Some("0-8191".to_string()));
@@ -252,7 +252,7 @@ async fn test_shard_get_minimal() {
252252
let shard = result.unwrap();
253253
assert_eq!(shard.uid, "shard:4:1");
254254
assert_eq!(shard.bdb_uid, 4);
255-
assert_eq!(shard.node_uid, 1);
255+
assert_eq!(shard.node_uid, "1");
256256
assert_eq!(shard.role, "master");
257257
assert_eq!(shard.status, "active");
258258
assert!(shard.slots.is_none());
@@ -453,9 +453,9 @@ async fn test_shard_list_by_node() {
453453
assert_eq!(shards.len(), 3);
454454

455455
// All shards should be on node 1
456-
assert_eq!(shards[0].node_uid, 1);
457-
assert_eq!(shards[1].node_uid, 1);
458-
assert_eq!(shards[2].node_uid, 1);
456+
assert_eq!(shards[0].node_uid, "1");
457+
assert_eq!(shards[1].node_uid, "1");
458+
assert_eq!(shards[2].node_uid, "1");
459459

460460
// Verify different databases
461461
assert_eq!(shards[0].bdb_uid, 1);

crates/redisctl/src/commands/enterprise/status.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use super::utils::*;
1818

1919
/// Comprehensive cluster status information
2020
#[derive(Debug, Clone, Serialize, Deserialize)]
21+
#[allow(dead_code)]
2122
pub struct ClusterStatus {
2223
/// Cluster information
2324
pub cluster: Value,
@@ -33,6 +34,7 @@ pub struct ClusterStatus {
3334

3435
/// Summary statistics for cluster health
3536
#[derive(Debug, Clone, Serialize, Deserialize)]
37+
#[allow(dead_code)]
3638
pub struct StatusSummary {
3739
/// Total number of nodes
3840
pub total_nodes: usize,
@@ -50,6 +52,7 @@ pub struct StatusSummary {
5052

5153
/// Sections to display in status output
5254
#[derive(Debug, Clone, Default)]
55+
#[allow(dead_code)]
5356
pub struct StatusSections {
5457
/// Show cluster information
5558
pub cluster: bool,
@@ -63,6 +66,7 @@ pub struct StatusSections {
6366

6467
impl StatusSections {
6568
/// Create sections showing all information
69+
#[allow(dead_code)]
6670
pub fn all() -> Self {
6771
Self {
6872
cluster: true,
@@ -73,12 +77,14 @@ impl StatusSections {
7377
}
7478

7579
/// Check if any section is enabled
80+
#[allow(dead_code)]
7681
pub fn any_enabled(&self) -> bool {
7782
self.cluster || self.nodes || self.databases || self.shards
7883
}
7984
}
8085

8186
/// Get comprehensive cluster status
87+
#[allow(dead_code)]
8288
pub async fn get_status(
8389
conn_mgr: &ConnectionManager,
8490
profile_name: Option<&str>,
@@ -163,6 +169,7 @@ pub async fn get_status(
163169
}
164170

165171
/// Calculate summary statistics from collected data
172+
#[allow(dead_code)]
166173
fn calculate_summary(nodes: &Value, databases: &Value, shards: &Value) -> StatusSummary {
167174
let empty_vec = vec![];
168175
let nodes_array = nodes.as_array().unwrap_or(&empty_vec);

0 commit comments

Comments
 (0)