vdev/commands/integration/
test.rs

1use anyhow::Result;
2use clap::Args;
3
4use crate::testing::integration::ComposeTestLocalConfig;
5
6/// Execute integration tests
7///
8/// If an environment is named, it is used to run the test. If the environment was not previously started,
9/// it is started before the test is run and stopped afterwards.
10///
11/// If no environment is named, but one has been started already, that environment is used for the test.
12///
13/// Otherwise, all environments are started, the test run, and then stopped, one by one.
14#[derive(Args, Debug)]
15#[command()]
16pub struct Cli {
17    /// The desired integration
18    integration: String,
19
20    /// The desired environment (optional)
21    environment: Option<String>,
22
23    /// Whether to compile the test runner with all integration test features
24    #[arg(short = 'a', long)]
25    build_all: bool,
26
27    /// Number of retries to allow on each integration test case.
28    #[arg(short = 'r', long)]
29    retries: Option<u8>,
30
31    /// Extra test command arguments
32    args: Vec<String>,
33}
34
35impl Cli {
36    pub fn exec(self) -> Result<()> {
37        crate::commands::compose_tests::test::exec(
38            ComposeTestLocalConfig::integration(),
39            &self.integration,
40            self.environment.as_ref(),
41            self.build_all,
42            self.retries.unwrap_or_default(),
43            &self.args,
44        )
45    }
46}