Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtcollins committed Aug 1, 2021
1 parent d336cb9 commit 80151ae
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/compile_schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,61 @@ mod test {
}
Ok(())
}

#[test]
fn merges_openapi() -> Result<()> {
{
let mut loader1 = MockSchemaSourceLoader::new();
loader1.expect_load_data().times(1).returning(|| {
let mut source = Box::new(MockSchemaSource::new());
source.expect_iter().times(1).returning(|| {
let mut iter = Box::new(MockSchemaSource_Stream::new());
iter.expect_poll_next()
.times(1)
.returning(|_cx| Poll::Ready(None));
iter
});
Ok(source)
});
loader1.expect_load_openapi().times(1).returning(|| {
Ok(OpenAPI {
openapi: "3.1".into(),
..Default::default()
})
});
let mut loader2 = MockSchemaSourceLoader::new();
loader2.expect_load_data().times(1).returning(|| {
let mut source = Box::new(MockSchemaSource::new());
source.expect_iter().times(1).returning(|| {
let mut iter = Box::new(MockSchemaSource_Stream::new());
iter.expect_poll_next()
.times(1)
.returning(|_cx| Poll::Ready(None));
iter
});
Ok(source)
});
// XXX: plan:
// add trait on OpenAPI taking additional structs returning new struct
// mock OpenAPI to let us capture one
//
let expected = OpenAPI {
openapi: "3.1".into(),
..Default::default()
};
loader2.expect_load_openapi().times(1).returning(|| {
Ok(expected.clone());
let api_sources: Vec<&mut dyn SchemaSourceLoader> = vec![&mut loader1, &mut loader2];
let mut compiler = CompileEverything::new(api_sources);
let expected = Schemas::OpenAPI(expected);
let mut output = MockOutputSchema::new();
output
.expect_output()
.return_once(|_| Ok(()));
aw!(compiler.compile(output))?;
}
Ok(())
}


}

0 comments on commit 80151ae

Please sign in to comment.