Move test generated clients into a buildable crate (#638)
This commit is contained in:
parent
71abb62e76
commit
d3e89232a3
|
@ -1 +1,3 @@
|
||||||
target/
|
target/
|
||||||
|
|
||||||
|
progenitor-impl/tests/output/Cargo.lock
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
[workspace]
|
||||||
|
|
||||||
|
[package]
|
||||||
|
name = "test-output"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
base64 = "0.21"
|
||||||
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
|
clap = { version = "4", features = ["string"] }
|
||||||
|
futures = "0.3"
|
||||||
|
httpmock = "0.7"
|
||||||
|
progenitor-client = { path = "../../../progenitor-client" }
|
||||||
|
rand = { version = "0.8", features = ["serde1"] }
|
||||||
|
regex = "1.10"
|
||||||
|
regress = "0.7"
|
||||||
|
reqwest = "0.11"
|
||||||
|
schemars = { version = "0.8", features = ["chrono", "uuid1"] }
|
||||||
|
serde = { features = ["derive"], version = "1" }
|
||||||
|
serde_json = "1"
|
||||||
|
uuid = { features = ["serde", "v4"], version = "1" }
|
||||||
|
|
||||||
|
[lints.rust]
|
||||||
|
unused_imports = "allow"
|
||||||
|
unused_variables= "allow"
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
|
needless_lifetimes = "allow"
|
||||||
|
redundant_field_names = "allow"
|
||||||
|
vec_init_then_push = "allow"
|
||||||
|
clone_on_copy = "allow"
|
||||||
|
unnecessary_to_owned = "allow"
|
||||||
|
to_string_in_format_args = "allow"
|
||||||
|
len_zero = "allow"
|
||||||
|
ptr_arg = "allow"
|
||||||
|
too_many_arguments = "allow"
|
|
@ -1,4 +1,4 @@
|
||||||
use sdk::*;
|
use crate::buildomat_builder::*;
|
||||||
pub struct Cli<T: CliOverride = ()> {
|
pub struct Cli<T: CliOverride = ()> {
|
||||||
client: Client,
|
client: Client,
|
||||||
over: T,
|
over: T,
|
|
@ -3,7 +3,7 @@ pub mod operations {
|
||||||
#![doc = r" wrappers for each operation. Each can be converted to"]
|
#![doc = r" wrappers for each operation. Each can be converted to"]
|
||||||
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
||||||
#![doc = r" be used to explicitly deviate from permitted values."]
|
#![doc = r" be used to explicitly deviate from permitted values."]
|
||||||
use sdk::*;
|
use crate::buildomat_builder::*;
|
||||||
pub struct ControlHoldWhen(httpmock::When);
|
pub struct ControlHoldWhen(httpmock::When);
|
||||||
impl ControlHoldWhen {
|
impl ControlHoldWhen {
|
||||||
pub fn new(inner: httpmock::When) -> Self {
|
pub fn new(inner: httpmock::When) -> Self {
|
|
@ -1,4 +1,4 @@
|
||||||
use sdk::*;
|
use crate::keeper_builder::*;
|
||||||
pub struct Cli<T: CliOverride = ()> {
|
pub struct Cli<T: CliOverride = ()> {
|
||||||
client: Client,
|
client: Client,
|
||||||
over: T,
|
over: T,
|
|
@ -3,7 +3,7 @@ pub mod operations {
|
||||||
#![doc = r" wrappers for each operation. Each can be converted to"]
|
#![doc = r" wrappers for each operation. Each can be converted to"]
|
||||||
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
||||||
#![doc = r" be used to explicitly deviate from permitted values."]
|
#![doc = r" be used to explicitly deviate from permitted values."]
|
||||||
use sdk::*;
|
use crate::keeper_builder::*;
|
||||||
pub struct EnrolWhen(httpmock::When);
|
pub struct EnrolWhen(httpmock::When);
|
||||||
impl EnrolWhen {
|
impl EnrolWhen {
|
||||||
pub fn new(inner: httpmock::When) -> Self {
|
pub fn new(inner: httpmock::When) -> Self {
|
|
@ -0,0 +1,34 @@
|
||||||
|
pub mod buildomat_builder;
|
||||||
|
pub mod buildomat_builder_tagged;
|
||||||
|
pub mod buildomat_cli;
|
||||||
|
//pub mod buildomat_httpmock;
|
||||||
|
pub mod buildomat_positional;
|
||||||
|
pub mod keeper_builder;
|
||||||
|
pub mod keeper_builder_tagged;
|
||||||
|
pub mod keeper_cli;
|
||||||
|
pub mod keeper_httpmock;
|
||||||
|
pub mod keeper_positional;
|
||||||
|
pub mod nexus_builder;
|
||||||
|
pub mod nexus_builder_tagged;
|
||||||
|
pub mod nexus_cli;
|
||||||
|
pub mod nexus_httpmock;
|
||||||
|
pub mod nexus_positional;
|
||||||
|
pub mod param_collision_builder;
|
||||||
|
pub mod param_collision_builder_tagged;
|
||||||
|
pub mod param_collision_cli;
|
||||||
|
pub mod param_collision_httpmock;
|
||||||
|
pub mod param_collision_positional;
|
||||||
|
pub mod param_overrides_builder;
|
||||||
|
pub mod param_overrides_builder_tagged;
|
||||||
|
pub mod param_overrides_cli;
|
||||||
|
pub mod param_overrides_httpmock;
|
||||||
|
pub mod param_overrides_positional;
|
||||||
|
pub mod propolis_server_builder;
|
||||||
|
pub mod propolis_server_builder_tagged;
|
||||||
|
pub mod propolis_server_cli;
|
||||||
|
//pub mod propolis_server_httpmock;
|
||||||
|
pub mod propolis_server_positional;
|
||||||
|
pub mod test_default_params_builder;
|
||||||
|
pub mod test_default_params_positional;
|
||||||
|
pub mod test_freeform_response;
|
||||||
|
pub mod test_renamed_parameters;
|
|
@ -1,4 +1,4 @@
|
||||||
use sdk::*;
|
use crate::nexus_builder::*;
|
||||||
pub struct Cli<T: CliOverride = ()> {
|
pub struct Cli<T: CliOverride = ()> {
|
||||||
client: Client,
|
client: Client,
|
||||||
over: T,
|
over: T,
|
|
@ -3,7 +3,7 @@ pub mod operations {
|
||||||
#![doc = r" wrappers for each operation. Each can be converted to"]
|
#![doc = r" wrappers for each operation. Each can be converted to"]
|
||||||
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
||||||
#![doc = r" be used to explicitly deviate from permitted values."]
|
#![doc = r" be used to explicitly deviate from permitted values."]
|
||||||
use sdk::*;
|
use crate::nexus_builder::*;
|
||||||
pub struct DiskViewByIdWhen(httpmock::When);
|
pub struct DiskViewByIdWhen(httpmock::When);
|
||||||
impl DiskViewByIdWhen {
|
impl DiskViewByIdWhen {
|
||||||
pub fn new(inner: httpmock::When) -> Self {
|
pub fn new(inner: httpmock::When) -> Self {
|
|
@ -1,4 +1,4 @@
|
||||||
use sdk::*;
|
use crate::param_collision_builder::*;
|
||||||
pub struct Cli<T: CliOverride = ()> {
|
pub struct Cli<T: CliOverride = ()> {
|
||||||
client: Client,
|
client: Client,
|
||||||
over: T,
|
over: T,
|
|
@ -3,7 +3,7 @@ pub mod operations {
|
||||||
#![doc = r" wrappers for each operation. Each can be converted to"]
|
#![doc = r" wrappers for each operation. Each can be converted to"]
|
||||||
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
||||||
#![doc = r" be used to explicitly deviate from permitted values."]
|
#![doc = r" be used to explicitly deviate from permitted values."]
|
||||||
use sdk::*;
|
use crate::param_collision_builder::*;
|
||||||
pub struct KeyGetWhen(httpmock::When);
|
pub struct KeyGetWhen(httpmock::When);
|
||||||
impl KeyGetWhen {
|
impl KeyGetWhen {
|
||||||
pub fn new(inner: httpmock::When) -> Self {
|
pub fn new(inner: httpmock::When) -> Self {
|
|
@ -1,4 +1,4 @@
|
||||||
use sdk::*;
|
use crate::param_overrides_builder::*;
|
||||||
pub struct Cli<T: CliOverride = ()> {
|
pub struct Cli<T: CliOverride = ()> {
|
||||||
client: Client,
|
client: Client,
|
||||||
over: T,
|
over: T,
|
|
@ -3,7 +3,7 @@ pub mod operations {
|
||||||
#![doc = r" wrappers for each operation. Each can be converted to"]
|
#![doc = r" wrappers for each operation. Each can be converted to"]
|
||||||
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
||||||
#![doc = r" be used to explicitly deviate from permitted values."]
|
#![doc = r" be used to explicitly deviate from permitted values."]
|
||||||
use sdk::*;
|
use crate::param_overrides_builder::*;
|
||||||
pub struct KeyGetWhen(httpmock::When);
|
pub struct KeyGetWhen(httpmock::When);
|
||||||
impl KeyGetWhen {
|
impl KeyGetWhen {
|
||||||
pub fn new(inner: httpmock::When) -> Self {
|
pub fn new(inner: httpmock::When) -> Self {
|
|
@ -1,4 +1,4 @@
|
||||||
use sdk::*;
|
use crate::propolis_server_builder::*;
|
||||||
pub struct Cli<T: CliOverride = ()> {
|
pub struct Cli<T: CliOverride = ()> {
|
||||||
client: Client,
|
client: Client,
|
||||||
over: T,
|
over: T,
|
|
@ -3,7 +3,7 @@ pub mod operations {
|
||||||
#![doc = r" wrappers for each operation. Each can be converted to"]
|
#![doc = r" wrappers for each operation. Each can be converted to"]
|
||||||
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
#![doc = r" its inner type with a call to `into_inner()`. This can"]
|
||||||
#![doc = r" be used to explicitly deviate from permitted values."]
|
#![doc = r" be used to explicitly deviate from permitted values."]
|
||||||
use sdk::*;
|
use crate::propolis_server_builder::*;
|
||||||
pub struct InstanceGetWhen(httpmock::When);
|
pub struct InstanceGetWhen(httpmock::When);
|
||||||
impl InstanceGetWhen {
|
impl InstanceGetWhen {
|
||||||
pub fn new(inner: httpmock::When) -> Self {
|
pub fn new(inner: httpmock::When) -> Self {
|
|
@ -49,7 +49,8 @@ fn reformat_code(content: TokenStream) -> String {
|
||||||
fn verify_apis(openapi_file: &str) {
|
fn verify_apis(openapi_file: &str) {
|
||||||
let mut in_path = PathBuf::from("../sample_openapi");
|
let mut in_path = PathBuf::from("../sample_openapi");
|
||||||
in_path.push(openapi_file);
|
in_path.push(openapi_file);
|
||||||
let openapi_stem = openapi_file.split('.').next().unwrap();
|
let openapi_stem =
|
||||||
|
openapi_file.split('.').next().unwrap().replace('-', "_");
|
||||||
|
|
||||||
let spec = load_api(in_path);
|
let spec = load_api(in_path);
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ fn verify_apis(openapi_file: &str) {
|
||||||
let mut generator = Generator::default();
|
let mut generator = Generator::default();
|
||||||
let output = generate_formatted(&mut generator, &spec);
|
let output = generate_formatted(&mut generator, &spec);
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}-positional.out", openapi_stem),
|
format!("tests/output/src/{}_positional.rs", openapi_stem),
|
||||||
&output,
|
&output,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ fn verify_apis(openapi_file: &str) {
|
||||||
);
|
);
|
||||||
let output = generate_formatted(&mut generator, &spec);
|
let output = generate_formatted(&mut generator, &spec);
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}-builder.out", openapi_stem),
|
format!("tests/output/src/{}_builder.rs", openapi_stem),
|
||||||
&output,
|
&output,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -94,21 +95,25 @@ fn verify_apis(openapi_file: &str) {
|
||||||
);
|
);
|
||||||
let output = generate_formatted(&mut generator, &spec);
|
let output = generate_formatted(&mut generator, &spec);
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}-builder-tagged.out", openapi_stem),
|
format!("tests/output/src/{}_builder_tagged.rs", openapi_stem),
|
||||||
&output,
|
&output,
|
||||||
);
|
);
|
||||||
|
|
||||||
// CLI generation.
|
// CLI generation.
|
||||||
let tokens = generator.cli(&spec, "sdk").unwrap();
|
let tokens = generator
|
||||||
|
.cli(&spec, &format!("crate::{openapi_stem}_builder"))
|
||||||
|
.unwrap();
|
||||||
let output = reformat_code(tokens);
|
let output = reformat_code(tokens);
|
||||||
|
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}-cli.out", openapi_stem),
|
format!("tests/output/src/{}_cli.rs", openapi_stem),
|
||||||
&output,
|
&output,
|
||||||
);
|
);
|
||||||
|
|
||||||
// httpmock generation.
|
// httpmock generation.
|
||||||
let code = generator.httpmock(&spec, "sdk").unwrap();
|
let code = generator
|
||||||
|
.httpmock(&spec, &format!("crate::{openapi_stem}_builder"))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// TODO pending #368
|
// TODO pending #368
|
||||||
let output = rustfmt_wrapper::rustfmt_config(
|
let output = rustfmt_wrapper::rustfmt_config(
|
||||||
|
@ -122,7 +127,7 @@ fn verify_apis(openapi_file: &str) {
|
||||||
|
|
||||||
let output = progenitor_impl::space_out_items(output).unwrap();
|
let output = progenitor_impl::space_out_items(output).unwrap();
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}-httpmock.out", openapi_stem),
|
format!("tests/output/src/{}_httpmock.rs", openapi_stem),
|
||||||
&output,
|
&output,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ fn test_renamed_parameters() {
|
||||||
let mut generator = Generator::default();
|
let mut generator = Generator::default();
|
||||||
let output = generate_formatted(&mut generator, &spec);
|
let output = generate_formatted(&mut generator, &spec);
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}.out", "test_renamed_parameters"),
|
format!("tests/output/src/{}.rs", "test_renamed_parameters"),
|
||||||
&output,
|
&output,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ fn test_freeform_response() {
|
||||||
let mut generator = Generator::default();
|
let mut generator = Generator::default();
|
||||||
let output = generate_formatted(&mut generator, &spec);
|
let output = generate_formatted(&mut generator, &spec);
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}.out", "test_freeform_response"),
|
format!("tests/output/src/{}.rs", "test_freeform_response"),
|
||||||
&output,
|
&output,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ fn test_default_params() {
|
||||||
let mut generator = Generator::default();
|
let mut generator = Generator::default();
|
||||||
let output = generate_formatted(&mut generator, &spec);
|
let output = generate_formatted(&mut generator, &spec);
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}.out", "test_default_params_positional"),
|
format!("tests/output/src/{}.rs", "test_default_params_positional"),
|
||||||
&output,
|
&output,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ fn test_default_params() {
|
||||||
);
|
);
|
||||||
let output = generate_formatted(&mut generator, &spec);
|
let output = generate_formatted(&mut generator, &spec);
|
||||||
expectorate::assert_contents(
|
expectorate::assert_contents(
|
||||||
format!("tests/output/{}.out", "test_default_params_builder"),
|
format!("tests/output/src/{}.rs", "test_default_params_builder"),
|
||||||
&output,
|
&output,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue