dropshot_api_manager/
test_util.rs

1// Copyright 2025 Oxide Computer Company
2
3use crate::{
4    BlessedSourceArgs, GeneratedSourceArgs,
5    apis::ManagedApis,
6    cmd::check::check_impl,
7    environment::{Environment, GeneratedSource},
8    output::{CheckResult, OutputOpts},
9};
10
11/// Check that a set of APIs is up-to-date.
12///
13/// This is meant to be called within a test.
14pub fn check_apis_up_to_date(
15    env: &Environment,
16    apis: &ManagedApis,
17) -> Result<CheckResult, anyhow::Error> {
18    // env.resolve(None) assumes that env.default_openapi_dir is where the
19    // OpenAPI documents live and doesn't need a further override. (If a custom
20    // directory is desired, it can always be passed in via `env`.)
21    let env = env.resolve(None)?;
22
23    let blessed_source =
24        BlessedSourceArgs { blessed_from_git: None, blessed_from_dir: None }
25            .to_blessed_source(&env)?;
26    let generated_source =
27        GeneratedSource::from(GeneratedSourceArgs { generated_from_dir: None });
28    let output = OutputOpts { color: clap::ColorChoice::Auto };
29
30    check_impl(apis, &env, &blessed_source, &generated_source, &output)
31}