Skip to content

Commit

Permalink
perf: fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
xz-dev committed Dec 21, 2024
1 parent 5583ec0 commit 8a62a1f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/core/config/data/rule_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod tests {
"hub_list": ["GitHub"]
}"#;

let config_list: RuleList = serde_json::from_str(&json).unwrap();
let config_list: RuleList = serde_json::from_str(json).unwrap();

// check app_config_list
assert_eq!(config_list.app_list.len(), 2);
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ mod tests {
async fn test_get_world_list_micro() {
let world_list_path = Path::new("./test_get_world_list_micro");
init_world_list(world_list_path).await.unwrap();
let _ = get_world_list();
let _ = get_world_list().await;
}
}
2 changes: 1 addition & 1 deletion src/core/config/world/world_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ mod tests {
let path = PathBuf::from(path_base).join(WORLD_CONFIG_LIST_NAME);

let _ = WorldList::new().load(&path);
assert_eq!(path.try_exists().is_ok_and(|x| x == false), true);
assert!(path.try_exists().is_ok_and(|x| !x));
}
}
4 changes: 2 additions & 2 deletions src/rpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ mod tests {
};
println!("{:?}", params);
let response: Result<bool, _> = client.request("init", params).await;
assert_eq!(response.unwrap(), true);
assert!(response.unwrap());
handle.stop().unwrap();
}
#[tokio::test]
Expand Down Expand Up @@ -255,7 +255,7 @@ mod tests {
let response: Result<bool, _> = client
.check_app_available(params.hub_uuid, params.app_data, params.hub_data)
.await;
assert_eq!(response.unwrap(), true);
assert!(response.unwrap());
handle.stop().unwrap();
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ mod tests {
let url = "https://example.com".parse().unwrap();
let result = https_get(url, &HashMap::new()).await;
assert!(result.is_ok());
assert!(result.unwrap().body.unwrap().len() > 0);
assert!(!result.unwrap().body.unwrap().is_empty());
}

#[tokio::test]
Expand Down Expand Up @@ -294,7 +294,7 @@ mod tests {
let url = "http://example.com".parse().unwrap();
let result = http_get(url, &HashMap::new()).await;
assert!(result.is_ok());
assert!(result.unwrap().body.unwrap().len() > 0);
assert!(!result.unwrap().body.unwrap().is_empty());
}

#[tokio::test]
Expand Down
14 changes: 7 additions & 7 deletions src/utils/versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ mod tests {
let version = Version {
string: "1.0.0".to_string(),
};
assert_eq!(version.is_valid(), true);
assert!(version.is_valid());
let version = Version {
string: "1.0.0-alpha".to_string(),
};
assert_eq!(version.is_valid(), true);
assert!(version.is_valid());
let version = Version {
string: "版本1.0.0".to_string(),
};
assert_eq!(version.is_valid(), true);
assert!(version.is_valid());
let chinese_suffix_version = Version {
string: "版本1.0.0 天行健".to_string(),
};
assert_eq!(chinese_suffix_version.is_valid(), true);
assert!(chinese_suffix_version.is_valid());
}

#[test]
fn test_version_is_invalid() {
let version = Version {
string: "xxx".to_string(),
};
assert_eq!(version.is_valid(), false);
assert!(!version.is_valid());
}

#[test]
Expand Down Expand Up @@ -119,7 +119,7 @@ mod tests {
let other_version = Version {
string: "1.0.1".to_string(),
};
assert_eq!(version < other_version, true);
assert!(version < other_version);
}

#[test]
Expand All @@ -130,7 +130,7 @@ mod tests {
let other_version = Version {
string: "1.0.1-alpha".to_string(),
};
assert_eq!(version > other_version, true);
assert!(version > other_version);
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions src/websdk/cloud_rules/cloud_rules_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod tests {
cloud_rules.renew().await.unwrap();
let list = cloud_rules.get_cloud_app_rules(|x| x.info.name == "UpgradeAll");
assert!(list.is_some());
let list = cloud_rules.get_cloud_app_rules(|x| x.info.name == "");
let list = cloud_rules.get_cloud_app_rules(|x| x.info.name.is_empty());
assert!(list.is_none());
}

Expand All @@ -82,9 +82,9 @@ mod tests {
cloud_rules.renew().await.unwrap();
let list = cloud_rules.get_cloud_app_rules_list(|x| x.info.name == "UpgradeAll");
assert_eq!(list.len(), 1);
let list = cloud_rules.get_cloud_app_rules_list(|x| x.info.name == "");
let list = cloud_rules.get_cloud_app_rules_list(|x| x.info.name.is_empty());
assert_eq!(list.len(), 0);
let list = cloud_rules.get_cloud_app_rules_list(|x| x.info.name != "");
let list = cloud_rules.get_cloud_app_rules_list(|x| !x.info.name.is_empty());
assert_eq!(
list.len(),
cloud_rules.get_config_list().app_config_list.len()
Expand All @@ -103,7 +103,7 @@ mod tests {
cloud_rules.renew().await.unwrap();
let list = cloud_rules.get_cloud_hub_rules(|x| x.info.hub_name == "GitHub");
assert!(list.is_some());
let list = cloud_rules.get_cloud_hub_rules(|x| x.info.hub_name == "");
let list = cloud_rules.get_cloud_hub_rules(|x| x.info.hub_name.is_empty());
assert!(list.is_none());
}
}
2 changes: 1 addition & 1 deletion src/websdk/repo/provider/base_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ mod tests {
async fn check_app_available(&self, fin: &FIn) -> FOut<bool> {
let id_map = fin.data_map.app_data;
let cache_map = fin.cache_map.clone();
FOut::new(cache_map.unwrap_or_default().get(id_map["id"]).is_some())
FOut::new(cache_map.unwrap_or_default().contains_key(id_map["id"]))
}

async fn get_releases(&self, fin: &FIn) -> FOut<Vec<ReleaseData>> {
Expand Down

0 comments on commit 8a62a1f

Please sign in to comment.