ml-cellar 0.2.0

CLI of ML model registry for minimum MLOps
Documentation
use assert_cmd::cargo::cargo_bin_cmd;

/// Test `ml-cellar docs {path}`
/// This test uses `tests/fixtures/test_registry/test_docs/` as test directory
/// Test to generate documentation for the model version located at `tests/fixtures/test_registry/test_docs/base/0.1/`
#[test]
fn test_docs() {
    let test_dir = "tests/fixtures/test_registry/test_docs/base/0.1/";
    let mut cmd = cargo_bin_cmd!("ml-cellar");
    cmd.arg("docs").arg(test_dir);
    let assert = cmd.assert().success();
    let output = String::from_utf8_lossy(&assert.get_output().stdout);

    // Check that the output contains the expected documentation
    assert!(output.contains("test_docs/base/0.1"));
    assert!(output.contains("Device: RTX4090"));
    assert!(output.contains("Training time: 2 GPU * 32 Batchsize * 4.7 days"));
    assert!(output.contains("name: myCOCO"));
    assert!(output.contains("mAP (0.5:0.95) | 0.40453625"));
    assert!(output.contains("bicycle | 916 | 0.2899"));
}

/// Test `ml-cellar docs {path} for missing path`
/// Expected to fail when path is missing.
#[test]
fn test_docs_missing_path() {
    let test_dir = "tests/fixtures/no_exist_path";
    let mut cmd = cargo_bin_cmd!("ml-cellar");
    cmd.arg("docs").arg(test_dir);
    cmd.assert().failure();
}

/// Test `ml-cellar docs {path} for missing template file`
/// This test uses `tests/fixtures/test_registry/test_docs_for_missing_template_file/` as test directory
/// Expected to fail when template file is missing.
#[test]
fn test_docs_missing_template_file() {
    let test_dir = "tests/fixtures/test_registry/test_docs_for_missing_template_file/base/0.1/";
    let mut cmd = cargo_bin_cmd!("ml-cellar");
    cmd.arg("docs").arg(test_dir);
    cmd.assert().failure();
}

/// Test `ml-cellar docs {path} for missing config setting`
/// This test uses `tests/fixtures/test_registry/test_docs_for_missing_config/` as test directory
/// `tests/fixtures/test_registry/test_docs_for_missing_config/config.toml` does not have `template_file` setting.
/// Expected to fail when config setting is missing.
#[test]
fn test_docs_missing_config_setting() {
    let test_dir = "tests/fixtures/test_registry/test_docs_for_missing_config/base/0.1/";
    let mut cmd = cargo_bin_cmd!("ml-cellar");
    cmd.arg("docs").arg(test_dir);
    cmd.assert().failure();
}