archunit/graph/fluentapi/
project_graphs.rsuse std::path::PathBuf;
use crate::common::ProjectLocator;
use super::ProjectGraphBuilder;
pub fn project_graph() -> ProjectGraphBuilder {
ProjectGraphBuilder::new(ProjectLocator::auto_detect())
}
pub fn dependency_graph() -> ProjectGraphBuilder {
project_graph()
}
pub fn project_graph_in(path: impl Into<PathBuf>) -> ProjectGraphBuilder {
ProjectGraphBuilder::new(ProjectLocator::from_path(path))
}
pub fn dependency_graph_in(path: impl Into<PathBuf>) -> ProjectGraphBuilder {
project_graph_in(path)
}
#[cfg(test)]
mod tests {
use std::path::Path;
use super::{dependency_graph, dependency_graph_in, project_graph, project_graph_in};
#[test]
fn default_entry_points_request_auto_detection() {
assert!(project_graph().project_locator().path().is_none());
assert!(dependency_graph().project_locator().path().is_none());
}
#[test]
fn explicit_entry_points_own_the_starting_path() {
assert_eq!(
project_graph_in("examples/layered")
.project_locator()
.path(),
Some(Path::new("examples/layered"))
);
assert_eq!(
dependency_graph_in("examples/aliased")
.project_locator()
.path(),
Some(Path::new("examples/aliased"))
);
}
}