Skip to content

Commit d32f493

Browse files
authored
Add integration tests that check various config options (#54)
1 parent d908d13 commit d32f493

File tree

4 files changed

+483
-1
lines changed

4 files changed

+483
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ $ docker-compose up -d
158158
$ cargo test --workspace
159159
$ docker-compose down
160160
```
161+
162+
Note, any output from these tests goes into `compressor_integration_tests/tmp/` so if this
163+
directory doesn't already exist then you will need to create it.

compressor_integration_tests/src/map_builder.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,58 @@ pub fn compressed_3_3_from_0_to_13_with_state() -> BTreeMap<i64, StateGroupEntry
160160
}
161161
expected
162162
}
163+
164+
/// Generates state map structure that corresponds to edges (with deltas)
165+
///
166+
/// Each group i has state:
167+
// ('node','is', i)
168+
// ('group', j, 'seen') - for all j less than i
169+
pub fn structure_from_edges_with_state(
170+
edges: BTreeMap<i64, i64>,
171+
start: i64,
172+
end: i64,
173+
) -> BTreeMap<i64, StateGroupEntry> {
174+
let mut expected: BTreeMap<i64, StateGroupEntry> = BTreeMap::new();
175+
176+
// Each group i has state:
177+
// ('node','is', i)
178+
// ('group', j, 'seen') - for all j less than i
179+
for i in start..=end {
180+
let prev = edges.get(&i);
181+
182+
//change from Option<&i64> to Option<i64>
183+
let prev = prev.copied();
184+
185+
// create a blank entry for it
186+
let mut entry = StateGroupEntry {
187+
in_range: true,
188+
prev_state_group: prev,
189+
state_map: StateMap::new(),
190+
};
191+
192+
// Add in all state between predecessor and now (non inclusive)
193+
if let Some(p) = prev {
194+
for j in (p + 1)..i {
195+
entry
196+
.state_map
197+
.insert("group", &j.to_string(), "seen".into());
198+
}
199+
} else {
200+
for j in start..i {
201+
entry
202+
.state_map
203+
.insert("group", &j.to_string(), "seen".into());
204+
}
205+
}
206+
207+
// add in the new state for this state group
208+
entry
209+
.state_map
210+
.insert("group", &i.to_string(), "seen".into());
211+
entry.state_map.insert("node", "is", i.to_string().into());
212+
213+
// put it into the expected map
214+
expected.insert(i, entry);
215+
}
216+
expected
217+
}

0 commit comments

Comments
 (0)