Skip to main content

api_testing_core/suite/runner/
context.rs

1use std::collections::HashSet;
2use std::path::PathBuf;
3
4use nils_term::progress::Progress;
5
6use crate::suite::results::SuiteRunResults;
7use crate::suite::schema::LoadedSuite;
8
9#[derive(Debug, Clone)]
10pub struct SuiteRunOptions {
11    pub required_tags: Vec<String>,
12    pub only_ids: HashSet<String>,
13    pub skip_ids: HashSet<String>,
14    pub allow_writes_flag: bool,
15    pub fail_fast: bool,
16    pub output_dir_base: PathBuf,
17    pub env_rest_url: String,
18    pub env_gql_url: String,
19    pub progress: Option<Progress>,
20}
21
22#[derive(Debug, Clone)]
23pub struct SuiteRunOutput {
24    pub run_dir_abs: PathBuf,
25    pub results: SuiteRunResults,
26}
27
28pub(super) fn suite_display_name(loaded: &LoadedSuite) -> String {
29    let name = loaded.manifest.name.trim();
30    if !name.is_empty() {
31        return name.to_string();
32    }
33    loaded
34        .suite_path
35        .file_name()
36        .and_then(|s| s.to_str())
37        .unwrap_or("suite")
38        .to_string()
39}
40
41pub(super) fn case_type_normalized(case_type_raw: &str) -> String {
42    case_type_raw.trim().to_ascii_lowercase()
43}
44
45pub(super) fn default_rest_flow_token_jq() -> String {
46    ".. | objects | (.accessToken? // .access_token? // .token? // empty) | select(type==\"string\" and length>0) | .".to_string()
47}