kiromi-ai-cli 0.2.2

Operator and developer CLI for the kiromi-ai-memory store: append, search, snapshot, regenerate, migrate-scheme, gc, audit-tail.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! Plan 12 phase J — `kiromi-ai-memory snapshot` smoke tests.

#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic, missing_docs)]

mod common;

use common::CliWorkspace;

#[test]
fn snapshot_create_then_list_then_delete_round_trip() {
    let ws = CliWorkspace::new();
    let _ = ws.init();

    let create = ws
        .cmd()
        .arg("snapshot")
        .arg("create")
        .arg("--tag")
        .arg("smoke")
        .output()
        .expect("snapshot create");
    assert!(
        create.status.success(),
        "create failed: {}",
        String::from_utf8_lossy(&create.stderr)
    );
    let stdout = String::from_utf8_lossy(&create.stdout);
    let id = stdout
        .lines()
        .next()
        .unwrap()
        .split_whitespace()
        .next()
        .unwrap()
        .to_string();
    assert!(!id.is_empty(), "no snapshot id printed; stdout={stdout}");

    let list = ws
        .cmd()
        .arg("snapshot")
        .arg("list")
        .output()
        .expect("snapshot list");
    assert!(list.status.success());
    let listed = String::from_utf8_lossy(&list.stdout);
    assert!(listed.contains(&id), "list missing id {id}; got: {listed}");

    let del = ws
        .cmd()
        .arg("snapshot")
        .arg("delete")
        .arg(&id)
        .output()
        .expect("snapshot delete");
    assert!(del.status.success());
}

#[test]
fn gc_smoke() {
    let ws = CliWorkspace::new();
    let _ = ws.init();
    let out = ws
        .cmd()
        .arg("gc")
        .arg("--retain-for")
        .arg("0")
        .arg("--dry-run")
        .output()
        .expect("gc");
    assert!(out.status.success(), "gc failed: {:?}", out);
}

#[test]
fn reindex_smoke() {
    let ws = CliWorkspace::new();
    let _ = ws.init();
    let out = ws
        .cmd()
        .arg("regenerate")
        .arg("reindex")
        .output()
        .expect("reindex");
    assert!(out.status.success(), "reindex failed: {:?}", out);
}