artifactize-core 0.13.1

The library behind artifactize: Artifacts, evals, reviews, the monitor and review models, and the shared operations every interface calls.
Documentation
//! Readiness status wire forms and the public report's aggregate severity.
use super::*;
use serde_json::json;

#[test]
fn readiness_check_status_wire_and_display_are_pinned() {
    for (status, wire) in [
        (CheckStatus::Pass, "PASS"),
        (CheckStatus::Warn, "WARN"),
        (CheckStatus::Fail, "FAIL"),
    ] {
        assert_eq!(status.to_string(), wire);
        let check = Check {
            name: "fixture",
            status,
            message: "pinned message".into(),
            details: Details::State { writable: true },
        };
        assert_eq!(
            serde_json::to_value(check).unwrap(),
            json!({
                "name":"fixture",
                "status":wire,
                "message":"pinned message",
                "details":{"writable":true},
            })
        );
    }
}

#[tokio::test]
async fn later_ready_checks_do_not_erase_a_configuration_failure() {
    let root = crate::test_os::tempdir();
    let repo = root.path().join("repo");
    let state = root.path().join("state");
    fs::create_dir(&repo).unwrap();
    fs::write(repo.join(crate::config::CONFIG_FILE), "name = [").unwrap();
    let report = doctor(Some(&state), Some(&repo)).await.unwrap();
    assert!(!report.ok);
    assert_eq!(report.checks[0].name, "config");
    assert_eq!(report.checks[0].status, CheckStatus::Fail);
    for name in ["state", "schema"] {
        let check = report
            .checks
            .iter()
            .find(|check| check.name == name)
            .unwrap();
        assert_eq!(check.status, CheckStatus::Pass, "{name}");
    }
    assert!(!state.join(store::DATABASE).exists());
}

#[test]
fn typed_details_preserve_null_and_flat_auth_wire_forms() {
    assert_eq!(serde_json::to_value(Details::None).unwrap(), json!(null));
    assert_eq!(
        serde_json::to_value(Details::Schema { schema: None }).unwrap(),
        json!({"schema":null})
    );
    let codex = Details::Codex {
        status: auth::codex::Status::Absent,
        test_endpoint: Some("http://localhost".into()),
        test_auth_endpoint: None,
    };
    assert_eq!(
        serde_json::to_value(codex).unwrap(),
        json!({"source":"none","expiresAt":null,"expired":false,"testEndpoint":"http://localhost"})
    );
}