Skip to content

Commit 867556b

Browse files
committed
chore(tests): fix all tests
1 parent 77d5e2c commit 867556b

File tree

4 files changed

+9
-41
lines changed

4 files changed

+9
-41
lines changed

src/api/explain_request.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ use serde::{Deserialize, Serialize};
1515
pub struct ExplainRequestInput {
1616
pub router_config: RouterConfig,
1717
pub example: Example,
18-
pub rules: TmpRules,
19-
}
20-
// FIXME: find a way to avoid creating this structure.
21-
// It would be more convenient to inline the structure
22-
#[derive(Deserialize, Debug, Clone)]
23-
pub struct TmpRules {
24-
#[serde(rename = "hydra:member")]
2518
pub rules: Vec<Rule>,
2619
}
2720

@@ -72,7 +65,7 @@ impl ExplainRequestOutput {
7265
) -> Result<ExplainRequestOutput, ExplainRequestOutputError> {
7366
let mut router = Router::<Rule>::from_config(explain_request_input.router_config);
7467

75-
for rule in explain_request_input.rules.rules.iter() {
68+
for rule in explain_request_input.rules.iter() {
7669
router.insert(rule.clone());
7770
}
7871

src/api/impact.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct ImpactInput {
1919
pub with_redirection_loop: bool,
2020
pub rule: Rule,
2121
pub action: String,
22-
pub rules: TmpRules,
22+
pub rules: Vec<Rule>,
2323
}
2424

2525
#[derive(Deserialize, Debug, Clone)]
@@ -31,14 +31,6 @@ pub struct ImpactProjectInput {
3131
pub change_set: RuleChangeSet,
3232
}
3333

34-
// FIXME: find a way to avoid creating this structure.
35-
// It would be more convenient to inline the structure
36-
#[derive(Deserialize, Debug, Clone)]
37-
pub struct TmpRules {
38-
#[serde(rename = "hydra:member")]
39-
pub rules: Vec<Rule>,
40-
}
41-
4234
// Output
4335

4436
#[derive(Serialize, Debug, Clone, Default)]
@@ -129,7 +121,7 @@ impl ImpactOutput {
129121
let mut router = Router::<Rule>::from_config(impact_input.router_config.clone());
130122
let mut trace_unique_router = Router::<Rule>::from_config(impact_input.router_config.clone());
131123

132-
for rule in impact_input.rules.rules.iter() {
124+
for rule in impact_input.rules.iter() {
133125
// Even for a "add" action, we remove a potential previous version
134126
// of the rule. This occurs when adding a rule (still in draft) and
135127
// then editing it (still in add / draft). But we want the very last

src/api/test_examples.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,14 @@ use serde::{Deserialize, Serialize};
1717
#[derive(Deserialize, Debug, Clone)]
1818
pub struct TestExamplesInput {
1919
pub router_config: RouterConfig,
20-
pub rules: TmpRules,
20+
pub rules: Vec<Rule>,
2121
}
2222

2323
#[derive(Deserialize, Debug, Clone)]
2424
pub struct TestExamplesProjectInput {
2525
pub change_set: RuleChangeSet,
2626
}
2727

28-
// FIXME: find a way to avoid creating this structure.
29-
// It would be more convenient to inline the structure
30-
#[derive(Deserialize, Debug, Clone)]
31-
pub struct TmpRules {
32-
#[serde(rename = "hydra:member")]
33-
pub rules: Vec<Rule>,
34-
}
35-
// Output
36-
3728
#[derive(Serialize, Debug, Clone, Default)]
3829
pub struct TestExamplesOutput {
3930
pub example_count: u32,
@@ -156,15 +147,15 @@ impl TestExamplesOutput {
156147
pub fn create_result(test_examples_input: TestExamplesInput) -> TestExamplesOutput {
157148
let mut router = Router::<Rule>::from_config(test_examples_input.router_config.clone());
158149

159-
for rule in test_examples_input.rules.rules.iter() {
150+
for rule in test_examples_input.rules.iter() {
160151
router.insert(rule.clone());
161152
}
162153

163154
router.cache(10000);
164155

165156
let mut results = TestExamplesOutput::default();
166157

167-
for rule in test_examples_input.rules.rules.iter() {
158+
for rule in test_examples_input.rules.iter() {
168159
if rule.examples.is_none() {
169160
continue;
170161
}

src/api/unit_ids.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,14 @@ use serde::{Deserialize, Serialize};
1313
#[derive(Deserialize, Debug, Clone)]
1414
pub struct UnitIdsInput {
1515
pub router_config: RouterConfig,
16-
pub rules: TmpRules,
16+
pub rules: Vec<Rule>,
1717
}
1818

1919
#[derive(Deserialize, Debug, Clone)]
2020
pub struct UnitIdsProjectInput {
2121
pub change_set: RuleChangeSet,
2222
}
2323

24-
// FIXME: find a way to avoid creating this structure.
25-
// It would be more convenient to inline the structure
26-
#[derive(Deserialize, Debug, Clone)]
27-
pub struct TmpRules {
28-
#[serde(rename = "hydra:member")]
29-
pub rules: Vec<Rule>,
30-
}
31-
3224
// Output
3325

3426
#[derive(Serialize, Debug, Clone, Default)]
@@ -114,15 +106,15 @@ impl UnitIdsOutput {
114106
let mut router = Router::<Rule>::from_config(unit_ids_input.router_config.clone());
115107
let router_config = router.config.clone();
116108

117-
for rule in unit_ids_input.rules.rules.iter() {
109+
for rule in unit_ids_input.rules.iter() {
118110
router.insert(rule.clone());
119111
}
120112

121113
router.cache(10000);
122114

123115
let mut rules = HashMap::new();
124116

125-
for rule in unit_ids_input.rules.rules {
117+
for rule in unit_ids_input.rules {
126118
if rule.examples.is_none() {
127119
continue;
128120
}

0 commit comments

Comments
 (0)