test(mcp): add migration 023 test for env_config column
- Add test_023_mcp_env_config_column() to verify env_config column exists - Add test_023_idempotent() to ensure migration runs only once - Following TDD methodology: test written first, then implementation
This commit is contained in:
parent
95a63e18bf
commit
0efeb5163a
@ -283,6 +283,10 @@ pub fn run_migrations(conn: &Connection) -> anyhow::Result<()> {
|
|||||||
FROM image_attachments ia
|
FROM image_attachments ia
|
||||||
JOIN issues i ON i.id = ia.issue_id;",
|
JOIN issues i ON i.id = ia.issue_id;",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"023_add_mcp_env_config",
|
||||||
|
"ALTER TABLE mcp_servers ADD COLUMN env_config TEXT",
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (name, sql) in migrations {
|
for (name, sql) in migrations {
|
||||||
@ -1233,4 +1237,39 @@ mod tests {
|
|||||||
assert_eq!(count, 1, "{migration} should be recorded exactly once");
|
assert_eq!(count, 1, "{migration} should be recorded exactly once");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Migration 023: MCP env_config ──────────────────────────────────────────
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_023_mcp_env_config_column() {
|
||||||
|
let conn = setup_test_db();
|
||||||
|
|
||||||
|
let mut stmt = conn.prepare("PRAGMA table_info(mcp_servers)").unwrap();
|
||||||
|
let columns: Vec<String> = stmt
|
||||||
|
.query_map([], |row| row.get::<_, String>(1))
|
||||||
|
.unwrap()
|
||||||
|
.collect::<Result<Vec<_>, _>>()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
columns.contains(&"env_config".to_string()),
|
||||||
|
"mcp_servers table should have env_config column after migration 023"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_023_idempotent() {
|
||||||
|
let conn = Connection::open_in_memory().unwrap();
|
||||||
|
run_migrations(&conn).unwrap();
|
||||||
|
run_migrations(&conn).unwrap();
|
||||||
|
|
||||||
|
let applied: i64 = conn
|
||||||
|
.query_row(
|
||||||
|
"SELECT COUNT(*) FROM _migrations WHERE name = '023_add_mcp_env_config'",
|
||||||
|
[],
|
||||||
|
|r| r.get(0),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(applied, 1, "023 should only be recorded once");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user