Skip to content

Commit

Permalink
WIP Make integration test use new API
Browse files Browse the repository at this point in the history
TODO: This fails to get the correct deps, why?
  • Loading branch information
seddonym committed Jan 10, 2025
1 parent cf23ebd commit b3f0600
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions rust/tests/large.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
use _rustgrimp::importgraph::ImportGraph;
use _rustgrimp::layers::{find_illegal_dependencies, Level};
use _rustgrimp::graph::{Graph, Level, Module};
use serde_json::{Map, Value};
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use std::fs;

#[test]
fn test_large_graph_deep_layers() {
let data = fs::read_to_string("tests/large_graph.json").expect("Unable to read file");
let value: Value = serde_json::from_str(&data).unwrap();
let items: &Map<String, Value> = value.as_object().unwrap();
let mut importeds_by_importer: HashMap<&str, HashSet<&str>> = HashMap::new();
let mut graph = Graph::default();
for (importer, importeds_value) in items.iter() {
let mut importeds = HashSet::new();
for imported in importeds_value.as_array().unwrap() {
importeds.insert(imported.as_str().unwrap());
graph.add_import(
&Module {
name: importer.to_string(),
},
&Module {
name: imported.to_string(),
},
);
}
importeds_by_importer.insert(importer, importeds);
}
let graph = ImportGraph::new(importeds_by_importer);
// TODO: for some reason this isn't populated in large_graph.json. Possibly there are other
// things missing too, which may be why find_illegal_dependencies_for_layers doesn't currently
// return any illegal dependencies.
graph.add_module(Module {
name: "mypackage".to_string(),
});

let deep_layers = vec![
"mypackage.plugins.5634303718.1007553798.8198145119.application.3242334296.1991886645",
Expand All @@ -39,7 +48,9 @@ fn test_large_graph_deep_layers() {
.collect();
let containers = HashSet::new();

let deps = find_illegal_dependencies(&graph, &levels, &containers);
let deps = graph
.find_illegal_dependencies_for_layers(levels, containers)
.unwrap();

assert_eq!(deps.len(), 8);
}

0 comments on commit b3f0600

Please sign in to comment.