Repository: influxdata/influxdb
File: influxdb3/tests/server/cli.rs (Rust)

Code before:
        .assert()
        .failure()
        .stdout(predicates::str::contains(expected_disabled));
}

#[test_log::test(tokio::test)]
async fn test_telemetry_disabled() {
    let serve_args = &[
        "serve",
        "--writer-id",
        "the-best-writer",
        "--object-store",
        "memory",
    ];

    let expected_disabled: &str = "Initializing TelemetryStore with upload disabled.";
    // validate no message when debug output disabled
    AssertCmd::cargo_bin("influxdb3")
        .unwrap()
        .args(serve_args)
        .arg("-v")
        .arg("--disable-telemetry-upload")
        .timeout(std::time::Duration::from_millis(500))
        .assert()
        .failure()
        .stdout(predicates::str::contains(expected_disabled).not());
}

#[test_log::test(tokio::test)]
async fn test_telemetry_enabled_with_debug_msg() {
    let serve_args = &[
        "serve",
        "--writer-id",
        "the-best-writer",
        "--object-store",
        "memory",
    ];

    let expected_enabled: &str =
        "Initializing TelemetryStore with upload enabled for http://localhost:9999.";

    // validate debug output shows which endpoint we are hitting when telemetry enabled
    AssertCmd::cargo_bin("influxdb3")
        .unwrap()
        .args(serve_args)
        .arg("-vv")
        .arg("--telemetry-endpoint")
        .arg("http://localhost:9999")
        .timeout(std::time::Duration::from_millis(500))
        .assert()
        .failure()

Review comment (refactor):
I think using `predicates` is fine but I've been following the existing pattern of using `assert_contains!` and `assert_not_contains!` macros from `test_helpers` just to keep it consistent. If those macros are lacking in functionality for your use case, definitely keep `predicates` in.

Code after:
        .failure()
        .get_output()
        .stdout
        .clone();
    let output = String::from_utf8(output).expect("must be able to convert output to String");
    assert_contains!(output, expected_disabled);
}

#[test_log::test(tokio::test)]
async fn test_telemetry_disabled() {
    let serve_args = &[
        "serve",
        "--writer-id",
        "the-best-writer",
        "--object-store",
        "memory",
    ];

    let expected_disabled: &str = "Initializing TelemetryStore with upload disabled.";
    // validate no message when debug output disabled
    let output = AssertCmd::cargo_bin("influxdb3")
        .unwrap()
        .args(serve_args)
        .arg("-v")
        .arg("--disable-telemetry-upload")
        .timeout(std::time::Duration::from_millis(500))
        .assert()
        .failure()
        .get_output()
        .stdout
        .clone();
    let output = String::from_utf8(output).expect("must be able to convert output to String");
    assert_not_contains!(output, expected_disabled);
}

#[test_log::test(tokio::test)]
async fn test_telemetry_enabled_with_debug_msg() {
    let serve_args = &[
        "serve",
        "--writer-id",
        "the-best-writer",
        "--object-store",
        "memory",
    ];

    let expected_enabled: &str =
        "Initializing TelemetryStore with upload enabled for http://localhost:9999.";

    // validate debug output shows which endpoint we are hitting when telemetry enabled
    let output = AssertCmd::cargo_bin("influxdb3")
        .unwrap()