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 env_grpc_url: String,
20    pub env_ws_url: String,
21    pub progress: Option<Progress>,
22}
23
24#[derive(Debug, Clone)]
25pub struct SuiteRunOutput {
26    pub run_dir_abs: PathBuf,
27    pub results: SuiteRunResults,
28}
29
30pub(super) fn suite_display_name(loaded: &LoadedSuite) -> String {
31    let name = loaded.manifest.name.trim();
32    if !name.is_empty() {
33        return name.to_string();
34    }
35    loaded
36        .suite_path
37        .file_name()
38        .and_then(|s| s.to_str())
39        .unwrap_or("suite")
40        .to_string()
41}
42
43pub(super) fn case_type_normalized(case_type_raw: &str) -> String {
44    let normalized = case_type_raw.trim().to_ascii_lowercase();
45    if normalized == "ws" {
46        "websocket".to_string()
47    } else {
48        normalized
49    }
50}
51
52pub(super) fn default_rest_flow_token_jq() -> String {
53    ".. | objects | (.accessToken? // .access_token? // .token? // empty) | select(type==\"string\" and length>0) | .".to_string()
54}