Skip to content

Commit

Permalink
add manually triggered tests to generate schema files for test file v…
Browse files Browse the repository at this point in the history
…alidation
  • Loading branch information
BenoitRanque committed Jan 1, 2025
1 parent 37bf016 commit 40a028f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/tests/tests-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ axum-test-helper = { workspace = true }
env_logger = { workspace = true }
hyper = { workspace = true, features = ["tcp"] }
reqwest = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true, features = ["raw_value"] }
sqlx = { workspace = true, features = [ "json", "postgres", "runtime-tokio-rustls" ] }
sqlx = { workspace = true, features = [
"json",
"postgres",
"runtime-tokio-rustls",
] }
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
url = { workspace = true }
uuid = { workspace = true, features = [ "v4", "fast-rng", "macro-diagnostics" ] }
uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] }
39 changes: 39 additions & 0 deletions crates/tests/tests-common/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,42 @@ async fn make_request<Response: for<'a> serde::Deserialize<'a>>(
)
})
}

/// Generate/Update static/query.schema.json
/// this test should be ignored unless explicitly invoked
#[ignore]
#[test]
fn generate_query_request_schema() {
let query_schema =
serde_json::to_string_pretty(&schemars::schema_for!(ndc_sdk::models::QueryRequest))
.expect("Should serialize query schema to json");
std::fs::write("../../../static/query.schema.json", query_schema)
.expect("Should be able to write out schema file");
}
/// Generate/Update static/mutation.schema.json
/// this test should be ignored unless explicitly invoked
#[ignore]
#[test]
fn generate_mutation_request_schema() {
let mutation_schema =
serde_json::to_string_pretty(&schemars::schema_for!(ndc_sdk::models::MutationRequest))
.expect("Should serialize mutation schema to json");
std::fs::write("../../../static/mutation.schema.json", mutation_schema)
.expect("Should be able to write out schema file");
}

/// Generate/Update static/configuration.schema.json
/// this test should be ignored unless explicitly invoked
#[ignore]
#[test]
fn generate_configuration_schema() {
let configuration_schema = serde_json::to_string_pretty(&schemars::schema_for!(
ndc_postgres_configuration::version5::ParsedConfiguration
))
.expect("Should serialize configuration schema to json");
std::fs::write(
"../../../static/configuration.schema.json",
configuration_schema,
)
.expect("Should be able to write out schema file");
}

0 comments on commit 40a028f

Please sign in to comment.