Skip to content

Commit

Permalink
test: deep object nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo committed Feb 17, 2022
1 parent cbfc257 commit a3ba4d3
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions core/src/schema/scenario.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,4 +1212,55 @@ mod tests {

scenario.build().unwrap();
}

#[test]
fn build_complex() {
let scenario = Scenario {
namespace: namespace!({
"collection": {
"type": "object",
"user": {
"type": "object",
"name": {"type": "string", "faker": {"generator": "first_name"}},
"age": {"type": "number", "range": {"low": 20, "high": 60}},
"contact": {
"type": "object",
"phone": {"type": "string", "faker": {"generator": "phone_number"}},
"email": {"type": "string", "faker": {"generator": "safe_email"}}
}
}
}
}),
scenario: scenario!({
"collection": {
"user": {
"type": "object",
"name": {},
"contact": {
"type": "object",
"email": {"type": "string", "faker": {"generator": "free_email"}}
}
}
}
}),
name: "test".to_string(),
};

let actual = scenario.build().unwrap();
let expected = namespace!({
"collection": {
"type": "object",
"user": {
"type": "object",
"name": {"type": "string", "faker": {"generator": "first_name"}},
"contact": {
"type": "object",
"email": {"type": "string", "faker": {"generator": "free_email"}}
}
}
}
});

assert_eq!(actual, expected);
}
}

0 comments on commit a3ba4d3

Please sign in to comment.