fix(db): persist project_id for new tuleap tickets
This commit is contained in:
parent
159ed59b5a
commit
0149e4ca97
1 changed files with 12 additions and 2 deletions
|
|
@ -62,8 +62,8 @@ impl ProcessedTicket {
|
||||||
|
|
||||||
let inserted_rows = conn.execute(
|
let inserted_rows = conn.execute(
|
||||||
"INSERT OR IGNORE INTO processed_tickets \
|
"INSERT OR IGNORE INTO processed_tickets \
|
||||||
(id, tracker_id, artifact_id, artifact_title, artifact_data, status, detected_at) \
|
(id, tracker_id, project_id, artifact_id, artifact_title, artifact_data, status, detected_at) \
|
||||||
VALUES (?1, ?2, ?3, ?4, ?5, 'Pending', ?6)",
|
VALUES (?1, ?2, (SELECT project_id FROM watched_trackers WHERE id = ?2), ?3, ?4, ?5, 'Pending', ?6)",
|
||||||
params![
|
params![
|
||||||
id,
|
id,
|
||||||
tracker_id,
|
tracker_id,
|
||||||
|
|
@ -319,6 +319,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_insert_if_new_creates_ticket() {
|
fn test_insert_if_new_creates_ticket() {
|
||||||
let (conn, tracker_id) = setup();
|
let (conn, tracker_id) = setup();
|
||||||
|
let expected_project_id = project_id_for_tracker(&conn, &tracker_id);
|
||||||
|
|
||||||
let result = ProcessedTicket::insert_if_new(
|
let result = ProcessedTicket::insert_if_new(
|
||||||
&conn,
|
&conn,
|
||||||
|
|
@ -337,6 +338,15 @@ mod tests {
|
||||||
assert_eq!(ticket.artifact_title, "Fix login bug");
|
assert_eq!(ticket.artifact_title, "Fix login bug");
|
||||||
assert!(ticket.analyst_report.is_none());
|
assert!(ticket.analyst_report.is_none());
|
||||||
assert!(ticket.processed_at.is_none());
|
assert!(ticket.processed_at.is_none());
|
||||||
|
|
||||||
|
let persisted_project_id: Option<String> = conn
|
||||||
|
.query_row(
|
||||||
|
"SELECT project_id FROM processed_tickets WHERE id = ?1",
|
||||||
|
params![ticket.id],
|
||||||
|
|row| row.get(0),
|
||||||
|
)
|
||||||
|
.expect("project_id query should succeed");
|
||||||
|
assert_eq!(persisted_project_id, Some(expected_project_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue