Skip to content

Commit

Permalink
ROVER-279 Fix clippies and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrainer committed Jan 8, 2025
1 parent 9738f02 commit 410d39d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 41 deletions.
40 changes: 19 additions & 21 deletions src/composition/supergraph/config/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ use rover_client::shared::GraphRef;
use tower::{MakeService, Service, ServiceExt};
use url::Url;

use crate::{
cli::Rover,
utils::{effect::read_stdin::ReadStdin, parsers::FileDescriptorType},
RoverError,
use self::{
fetch_remote_subgraph::FetchRemoteSubgraphFactory,
fetch_remote_subgraphs::FetchRemoteSubgraphsRequest, state::ResolveSubgraphs,
};

use super::{
error::ResolveSubgraphError,
federation::{
Expand All @@ -41,10 +39,10 @@ use super::{
lazy::LazilyResolvedSupergraphConfig,
unresolved::UnresolvedSupergraphConfig,
};

use self::{
fetch_remote_subgraph::FetchRemoteSubgraphFactory,
fetch_remote_subgraphs::FetchRemoteSubgraphsRequest, state::ResolveSubgraphs,
use crate::{
cli::Rover,
utils::{effect::read_stdin::ReadStdin, parsers::FileDescriptorType},
RoverError,
};

pub mod fetch_remote_subgraph;
Expand Down Expand Up @@ -439,6 +437,7 @@ fn maybe_name_from_dir() -> Option<String> {

#[cfg(test)]
mod tests {
use std::sync::Arc;
use std::{collections::BTreeMap, str::FromStr};

use anyhow::Result;
Expand All @@ -458,6 +457,14 @@ mod tests {
use tower::{ServiceBuilder, ServiceExt};
use tower_test::mock::Handle;

use super::{
fetch_remote_subgraph::{
FetchRemoteSubgraphError, FetchRemoteSubgraphFactory, FetchRemoteSubgraphRequest,
MakeFetchRemoteSubgraphError, RemoteSubgraph,
},
fetch_remote_subgraphs::{FetchRemoteSubgraphsRequest, MakeFetchRemoteSubgraphsError},
MockPrompt, SupergraphConfigResolver,
};
use crate::{
composition::supergraph::config::{
error::ResolveSubgraphError,
Expand All @@ -475,15 +482,6 @@ mod tests {
},
};

use super::{
fetch_remote_subgraph::{
FetchRemoteSubgraphError, FetchRemoteSubgraphFactory, FetchRemoteSubgraphRequest,
MakeFetchRemoteSubgraphError, RemoteSubgraph,
},
fetch_remote_subgraphs::{FetchRemoteSubgraphsRequest, MakeFetchRemoteSubgraphsError},
MockPrompt, SupergraphConfigResolver,
};

/// Test showing that federation version is selected from the user-specified fed version
/// over local supergraph config, remote composition version, or version inferred from
/// resolved SDLs
Expand Down Expand Up @@ -695,7 +693,7 @@ mod tests {
.boxed_clone()
.map_err(|err| ResolveSubgraphError::IntrospectionError {
subgraph_name: "dont-call-me".to_string(),
source: err,
source: Arc::new(err),
})
.service(resolve_introspect_subgraph_service.into_inner()))
}
Expand Down Expand Up @@ -928,7 +926,7 @@ mod tests {
.boxed_clone()
.map_err(|err| ResolveSubgraphError::IntrospectionError {
subgraph_name: "dont-call-me".to_string(),
source: err,
source: Arc::new(err),
})
.service(resolve_introspect_subgraph_service.into_inner()))
}
Expand Down Expand Up @@ -1161,7 +1159,7 @@ mod tests {
.boxed_clone()
.map_err(|err| ResolveSubgraphError::IntrospectionError {
subgraph_name: "dont-call-me".to_string(),
source: err,
source: Arc::new(err),
})
.service(resolve_introspect_subgraph_service.into_inner()))
}
Expand Down
9 changes: 5 additions & 4 deletions src/composition/supergraph/config/unresolved/supergraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl UnresolvedSupergraphConfig {

#[cfg(test)]
mod tests {
use std::sync::Arc;
use std::{
collections::{BTreeMap, HashSet},
str::FromStr,
Expand Down Expand Up @@ -436,7 +437,7 @@ mod tests {
.boxed_clone()
.map_err(move |err| ResolveSubgraphError::IntrospectionError {
subgraph_name: introspect_subgraph_name.to_string(),
source: err,
source: Arc::new(err),
})
.service(resolve_introspect_subgraph_service.into_inner()),
);
Expand Down Expand Up @@ -464,7 +465,7 @@ mod tests {
let introspect_subgraph_name = introspect_subgraph_name.to_string();
move |err| ResolveSubgraphError::IntrospectionError {
subgraph_name: introspect_subgraph_name.to_string(),
source: err,
source: Arc::new(err),
}
})
.service(resolve_introspect_subgraph_factory.into_inner()),
Expand Down Expand Up @@ -732,7 +733,7 @@ mod tests {
.boxed_clone()
.map_err(move |err| ResolveSubgraphError::IntrospectionError {
subgraph_name: introspect_subgraph_name.to_string(),
source: err,
source: Arc::new(err),
})
.service(resolve_introspect_subgraph_service.into_inner()),
);
Expand All @@ -745,7 +746,7 @@ mod tests {
let introspect_subgraph_name = introspect_subgraph_name.to_string();
move |err| ResolveSubgraphError::IntrospectionError {
subgraph_name: introspect_subgraph_name.to_string(),
source: err,
source: Arc::new(err),
}
})
.service(resolve_introspect_subgraph_factory.into_inner()),
Expand Down
20 changes: 9 additions & 11 deletions src/composition/watchers/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ impl SubtaskHandleStream for FederationWatcher {
) -> AbortHandle {
tokio::task::spawn(async move {
while let Some(recv_res) = input.next().await {
match recv_res {
Err(SupergraphConfigSerialisationError::DeserializingConfigError {
source,
}) => {
let _ = sender
.send(CompositionEvent::Error(
CompositionError::InvalidSupergraphConfig(source.message()),
))
.tap_err(|err| error!("{:?}", err));
}
_ => (),
if let Err(SupergraphConfigSerialisationError::DeserializingConfigError {
source,
}) = recv_res
{
let _ = sender
.send(CompositionEvent::Error(
CompositionError::InvalidSupergraphConfig(source.message()),
))
.tap_err(|err| error!("{:?}", err));
}
}
})
Expand Down
6 changes: 4 additions & 2 deletions src/composition/watchers/subgraphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ impl SubgraphHandles {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use apollo_federation_types::config::SchemaSource;
use camino::Utf8PathBuf;
use speculoos::prelude::*;
Expand Down Expand Up @@ -494,7 +496,7 @@ mod tests {
send_response.send_response(
ServiceBuilder::new()
.boxed_clone()
.map_err(ResolveSubgraphError::ServiceReady)
.map_err(|e| ResolveSubgraphError::ServiceReady(Arc::new(e)))
.service(resolve_introspect_subgraph_service.into_inner()),
);
}
Expand All @@ -503,7 +505,7 @@ mod tests {
let resolve_introspect_subgraph_factory: ResolveIntrospectSubgraphFactory =
ServiceBuilder::new()
.boxed_clone()
.map_err(ResolveSubgraphError::ServiceReady)
.map_err(|e| ResolveSubgraphError::ServiceReady(Arc::new(e)))
.service(resolve_introspect_subgraph_factory.into_inner());

let (fetch_remote_subgraph_service, mut fetch_remote_subgraph_service_handle) =
Expand Down
4 changes: 1 addition & 3 deletions src/composition/watchers/watcher/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,15 @@ mod tests {
use std::{fs::OpenOptions, io::Write, time::Duration};

use apollo_federation_types::config::{SchemaSource, SubgraphConfig};
use assert_fs::TempDir;
use speculoos::prelude::*;
use tokio::time::timeout;
use tower::ServiceExt;
use tracing_test::traced_test;

use super::*;
use crate::composition::supergraph::config::full::file::ResolveFileSubgraph;
use crate::composition::supergraph::config::unresolved::UnresolvedSubgraph;

use super::*;

#[tokio::test]
#[traced_test(level = "error")]
async fn it_watches() {
Expand Down

0 comments on commit 410d39d

Please sign in to comment.