Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: various clippy warnings #1955

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/command/config/whoami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ mod tests {
let graph_identity = get_identity(Actor::GRAPH);
let other_identity = get_identity(Actor::OTHER);

assert_eq!(WhoAmI::is_valid_actor_type(&woi, &user_identity), true);
assert_eq!(WhoAmI::is_valid_actor_type(&woi, &graph_identity), true);
assert_eq!(WhoAmI::is_valid_actor_type(&woi, &other_identity), false);
assert!(WhoAmI::is_valid_actor_type(&woi, &user_identity));
assert!(WhoAmI::is_valid_actor_type(&woi, &graph_identity));
assert!(!WhoAmI::is_valid_actor_type(&woi, &other_identity));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/command/dev/router/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ mod tests {
},
skip_update: true,
},
server.address().clone(),
*server.address(),
"".to_string(),
None,
StudioClientConfig::new(
Expand Down
2 changes: 1 addition & 1 deletion src/command/supergraph/compose/do_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ mod tests {
.unwrap()
.get_subgraph_definitions()
.unwrap();
let film_subgraph = subgraph_definitions.get(0).unwrap();
let film_subgraph = subgraph_definitions.first().unwrap();
let people_subgraph = subgraph_definitions.get(1).unwrap();

assert_eq!(film_subgraph.name, "films");
Expand Down
36 changes: 18 additions & 18 deletions src/command/supergraph/resolve_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,6 @@ pub(crate) fn expand_supergraph_yaml(content: &str) -> RoverResult<SupergraphCon
.and_then(|v| serde_yaml::from_value(v).map_err(RoverError::from))
}

#[cfg(test)]
mod test_expand_supergraph_yaml {
use apollo_federation_types::config::FederationVersion;

#[test]
fn test_supergraph_yaml_int_version() {
let yaml = r#"
federation_version: 1
subgraphs:
"#;
let config = super::expand_supergraph_yaml(yaml).unwrap();
assert_eq!(
config.get_federation_version(),
Some(FederationVersion::LatestFedOne)
);
}
}

pub(crate) fn resolve_supergraph_yaml(
unresolved_supergraph_yaml: &FileDescriptorType,
client_config: StudioClientConfig,
Expand Down Expand Up @@ -286,3 +268,21 @@ pub(crate) fn resolve_supergraph_yaml(

Ok(resolved_supergraph_config)
}

#[cfg(test)]
mod test_expand_supergraph_yaml {
use apollo_federation_types::config::FederationVersion;

#[test]
fn test_supergraph_yaml_int_version() {
let yaml = r#"
federation_version: 1
subgraphs:
"#;
let config = super::expand_supergraph_yaml(yaml).unwrap();
assert_eq!(
config.get_federation_version(),
Some(FederationVersion::LatestFedOne)
);
}
}
6 changes: 2 additions & 4 deletions src/utils/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ mod tests {
#[test]
fn it_correctly_parses_stdin_flag() {
let fd = FileDescriptorType::from_str("-").unwrap();

match fd {
FileDescriptorType::File(_) => panic!("parsed incorrectly as file"),
_ => (),
if let FileDescriptorType::File(_) = fd {
panic!("parsed incorrectly as file")
}
}

Expand Down
14 changes: 7 additions & 7 deletions tests/installers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde_json::Value;
fn it_has_nix_installer() {
let nix_installer_path = get_binstall_scripts_root().join("nix").join("install.sh");
let nix_script =
fs::read_to_string(&nix_installer_path).expect("Could not read nix installer script");
fs::read_to_string(nix_installer_path).expect("Could not read nix installer script");
assert!(!nix_script.is_empty())
}

Expand All @@ -22,7 +22,7 @@ fn it_has_windows_installer() {
let windows_installer_path = get_binstall_scripts_root()
.join("windows")
.join("install.ps1");
let windows_script = fs::read_to_string(&windows_installer_path)
let windows_script = fs::read_to_string(windows_installer_path)
.expect("Could not read windows installer script");
assert!(!windows_script.is_empty())
}
Expand Down Expand Up @@ -75,7 +75,7 @@ fn latest_plugins_are_valid_versions() {
.as_str()
.expect("JSON malformed: `supergraph.versions.latest-0` was not a string");

assert!(latest_federation_one.starts_with("v"));
assert!(latest_federation_one.starts_with('v'));
Version::parse(&latest_federation_one.to_string()[1..])
.expect("JSON malformed: `supergraph.versions.latest-0` was not valid semver");

Expand All @@ -85,12 +85,12 @@ fn latest_plugins_are_valid_versions() {
.as_str()
.expect("JSON malformed: `supergraph.versions.latest-2` was not a string");

assert!(latest_federation_two.starts_with("v"));
assert!(latest_federation_two.starts_with('v'));
Version::parse(&latest_federation_two.to_string()[1..])
.expect("JSON malformed: `supergraph.versions.latest-2 was not valid semver");

let supergraph_repository = Url::parse(
&supergraph
supergraph
.get("repository")
.expect("JSON malformed: `supergraph.resitory` does not exist")
.as_str()
Expand All @@ -112,12 +112,12 @@ fn latest_plugins_are_valid_versions() {
.as_str()
.expect("JSON malformed: `router.versions.latest-1` was not a string");

assert!(latest_router.starts_with("v"));
assert!(latest_router.starts_with('v'));
Version::parse(&latest_router.to_string()[1..])
.expect("JSON malformed: `router.versions.latest-1 was not valid semver");

let router_repository = Url::parse(
&router
router
.get("repository")
.expect("JSON malformed: `router.resitory` does not exist")
.as_str()
Expand Down