test(core): add integration tests for agentd-core migrate subcommand#1133
test(core): add integration tests for agentd-core migrate subcommand#1133geoffjay wants to merge 2 commits intoissue-1125from
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
Four scenarios exercised via std::process::Command against isolated temp databases (--db-path flag added in #1125): 1. migrate up + status round-trip: verifies all migrations applied 2. status on empty database: verifies all migrations shown as pending 3. migrate down --yes + status: verifies latest migration rolled back 4. migrate down without --yes on non-TTY: verifies non-zero exit + hint Closes #1127
geoffjay
left a comment
There was a problem hiding this comment.
Review: test(core): add integration tests for agentd-core migrate subcommand
LGTM — cannot self-approve, posting as comment.
Stack note
This branch (issue-1127) is stacked on:
- #1132 (issue-1125):
feat(core): add clap CLI with migrate subcommand to agentd-core binary— still open - #1131 (issue-1124):
feat(core): expose apply/status/rollback migration helpers from lib.rs— still open - #1130, #1129 below that
The entire upstack must merge before this lands. The tests depend on the migrate subcommand and --db-path flag introduced in #1132.
What was verified
- Binary target:
[[bin]] name = "agentd-core"is declared inCargo.toml→env!("CARGO_BIN_EXE_agentd-core")resolves correctly at test time. ✓ tempfiledev-dep: present attempfile = "3.14"in[dev-dependencies]. ✓--db-pathflag: all threeMigrateActionvariants (Status,Up,Down) expose#[arg(long)] db_path: Option<PathBuf>. ✓- Output string assertions cross-checked against
main.rs:"up to date"/"applied"— emitted byrun_migrate_up✓"0 pending"— appears in the summary line"N applied, 0 pending"✓"0 applied"(empty DB) — summary line is"0 applied, N pending"✓"rolled back"— emitted as"✓ rolled back {migration}"✓stderr.contains("--yes") || .contains("TTY")— theanyhow::bail!message is"stdin is not a TTY — pass --yes to confirm rollback without a prompt"— hits both branches ✓
- Non-zero exit on missing TTY:
anyhow::bail!propagates throughmain() -> Result<()>which prints to stderr and exits non-zero. ✓ - Isolation: each test creates its own
TempDir— no shared state between runs. ✓ - Scope: single new file, no changes to production code. ✓
Non-blocking suggestions
-
test_status_on_empty_database— the DB file does not exist before the call; the test succeeds becausemigration_status_for_path(via SeaORM) creates the file on first connection. Worth a one-line comment documenting this implicit side-effect so the intent is clear to future readers. -
Missing
--allcoverage:migrate down --all --yesis not exercised. A test verifying that all N migrations end up pending after--allwould complete the matrix. Non-blocking for this PR. -
Idempotency: running
migrate uptwice and asserting the second run still exits zero with"0 pending"would guard against non-idempotent migration regressions. Nice-to-have.
Adds
crates/core/tests/migrate_cli.rswith 4 scenarios exercised viastd::process::Commandagainst isolated temp databases: up+status round-trip, status on empty DB, down+status rollback, and non-TTY down without--yesexits non-zero.Closes #1127