From e46a2fe590b810bef50d9338827f8cf082bda1cb Mon Sep 17 00:00:00 2001 From: teernisse Date: Thu, 12 Mar 2026 10:07:27 -0400 Subject: [PATCH] test(core): add lookup-by-gitlab_project_id test for projects table Validates that the projects table schema uses gitlab_project_id (not gitlab_id) and that queries filtering by this column return the correct project. Uses the test helper convention where insert_project sets gitlab_project_id = id * 100. --- src/core/project_tests.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/core/project_tests.rs b/src/core/project_tests.rs index e28129d..f526ed4 100644 --- a/src/core/project_tests.rs +++ b/src/core/project_tests.rs @@ -154,3 +154,25 @@ fn test_percent_not_wildcard() { let id = resolve_project(&conn, "a%b").unwrap(); assert_eq!(id, 1); } + +#[test] +fn test_lookup_by_gitlab_project_id() { + use crate::test_support::{insert_project as insert_proj, setup_test_db}; + + let conn = setup_test_db(); + insert_proj(&conn, 1, "team/alpha"); + insert_proj(&conn, 2, "team/beta"); + + // insert_project sets gitlab_project_id = id * 100 + let path: String = conn + .query_row( + "SELECT path_with_namespace FROM projects + WHERE gitlab_project_id = ?1 + ORDER BY id LIMIT 1", + rusqlite::params![200_i64], + |row| row.get(0), + ) + .unwrap(); + + assert_eq!(path, "team/beta"); +}