test: Remove redundant comments from test files
Applies the same doc comment cleanup to test files: - Removes test module headers (//! lines) - Removes obvious test function comments - Retains comments explaining non-obvious test scenarios Test names should be descriptive enough to convey intent without additional comments. Complex test setup or assertions that need explanation retain their comments. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
//! Golden query test suite.
|
||||
//!
|
||||
//! Verifies end-to-end search quality with known-good expected results.
|
||||
//! Uses a seeded SQLite DB with deterministic fixture data and no external
|
||||
//! dependencies (no Ollama, no GitLab).
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use rusqlite::Connection;
|
||||
@@ -12,7 +6,6 @@ use std::path::PathBuf;
|
||||
|
||||
use lore::search::{FtsQueryMode, SearchFilters, SearchMode, apply_filters, search_fts};
|
||||
|
||||
/// A golden query test case.
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct GoldenQuery {
|
||||
query: String,
|
||||
@@ -42,12 +35,10 @@ fn load_golden_queries() -> Vec<GoldenQuery> {
|
||||
.unwrap_or_else(|e| panic!("Failed to parse golden queries: {}", e))
|
||||
}
|
||||
|
||||
/// Create an in-memory database with FTS5 schema and seed deterministic fixture data.
|
||||
fn create_seeded_db() -> Connection {
|
||||
let conn = Connection::open_in_memory().unwrap();
|
||||
conn.pragma_update(None, "foreign_keys", "ON").unwrap();
|
||||
|
||||
// Apply migrations 001-008 (FTS5)
|
||||
let migrations_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("migrations");
|
||||
for version in 1..=8 {
|
||||
let entries: Vec<_> = std::fs::read_dir(&migrations_dir)
|
||||
@@ -65,7 +56,6 @@ fn create_seeded_db() -> Connection {
|
||||
.unwrap_or_else(|e| panic!("Migration {} failed: {}", version, e));
|
||||
}
|
||||
|
||||
// Seed project
|
||||
conn.execute(
|
||||
"INSERT INTO projects (id, gitlab_project_id, path_with_namespace, web_url)
|
||||
VALUES (1, 100, 'group/project', 'https://gitlab.example.com/group/project')",
|
||||
@@ -73,9 +63,7 @@ fn create_seeded_db() -> Connection {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// Seed deterministic documents
|
||||
let documents = vec![
|
||||
// id=1: Auth issue (matches: authentication, login, OAuth, JWT, token, refresh)
|
||||
(
|
||||
1,
|
||||
"issue",
|
||||
@@ -86,7 +74,6 @@ fn create_seeded_db() -> Connection {
|
||||
Multiple users reported authentication failures across all OAuth providers.",
|
||||
"testuser",
|
||||
),
|
||||
// id=2: User profile MR (matches: user, profile, avatar, upload)
|
||||
(
|
||||
2,
|
||||
"merge_request",
|
||||
@@ -96,7 +83,6 @@ fn create_seeded_db() -> Connection {
|
||||
responsive design for mobile and desktop viewports.",
|
||||
"developer1",
|
||||
),
|
||||
// id=3: Database migration issue (matches: database, migration, PostgreSQL, schema)
|
||||
(
|
||||
3,
|
||||
"issue",
|
||||
@@ -106,7 +92,6 @@ fn create_seeded_db() -> Connection {
|
||||
rewritten to use the new schema modification syntax. All staging environments affected.",
|
||||
"dba_admin",
|
||||
),
|
||||
// id=4: Performance MR (matches: performance, optimization, caching, query)
|
||||
(
|
||||
4,
|
||||
"merge_request",
|
||||
@@ -116,7 +101,6 @@ fn create_seeded_db() -> Connection {
|
||||
to 180ms. Added connection pooling and prepared statement caching.",
|
||||
"senior_dev",
|
||||
),
|
||||
// id=5: API rate limiting discussion (matches: API, rate, limiting, throttle)
|
||||
(
|
||||
5,
|
||||
"discussion",
|
||||
@@ -127,7 +111,6 @@ fn create_seeded_db() -> Connection {
|
||||
Need to handle burst traffic during peak hours without throttling legitimate users.",
|
||||
"architect",
|
||||
),
|
||||
// id=6: UI/CSS issue (matches: CSS, styling, frontend, responsive, UI)
|
||||
(
|
||||
6,
|
||||
"issue",
|
||||
@@ -138,7 +121,6 @@ fn create_seeded_db() -> Connection {
|
||||
conflicting CSS specificity with the theme system.",
|
||||
"frontend_dev",
|
||||
),
|
||||
// id=7: CI/CD MR (matches: CI, CD, pipeline, deployment, Docker)
|
||||
(
|
||||
7,
|
||||
"merge_request",
|
||||
@@ -148,7 +130,6 @@ fn create_seeded_db() -> Connection {
|
||||
support for failed deployments. Pipeline runtime reduced from 45min to 12min.",
|
||||
"devops_lead",
|
||||
),
|
||||
// id=8: Security issue (matches: security, vulnerability, XSS, injection)
|
||||
(
|
||||
8,
|
||||
"issue",
|
||||
@@ -169,7 +150,6 @@ fn create_seeded_db() -> Connection {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Seed labels for filtered queries
|
||||
conn.execute_batch(
|
||||
"INSERT INTO document_labels (document_id, label_name) VALUES (1, 'bug');
|
||||
INSERT INTO document_labels (document_id, label_name) VALUES (1, 'authentication');
|
||||
@@ -212,7 +192,6 @@ fn golden_queries_all_pass() {
|
||||
for (i, gq) in queries.iter().enumerate() {
|
||||
let mode = SearchMode::parse(&gq.mode).unwrap_or(SearchMode::Lexical);
|
||||
|
||||
// For lexical-only golden queries (no Ollama needed)
|
||||
assert_eq!(
|
||||
mode,
|
||||
SearchMode::Lexical,
|
||||
@@ -221,11 +200,9 @@ fn golden_queries_all_pass() {
|
||||
gq.mode
|
||||
);
|
||||
|
||||
// Run FTS search
|
||||
let fts_results = search_fts(&conn, &gq.query, 50, FtsQueryMode::Safe).unwrap();
|
||||
let doc_ids: Vec<i64> = fts_results.iter().map(|r| r.document_id).collect();
|
||||
|
||||
// Apply filters if any
|
||||
let filters = build_search_filters(&gq.filters);
|
||||
let filtered_ids = if filters.has_any_filter() {
|
||||
apply_filters(&conn, &doc_ids, &filters).unwrap()
|
||||
@@ -233,7 +210,6 @@ fn golden_queries_all_pass() {
|
||||
doc_ids.clone()
|
||||
};
|
||||
|
||||
// Check min_results
|
||||
if filtered_ids.len() < gq.min_results {
|
||||
failures.push(format!(
|
||||
"FAIL [{}] \"{}\": expected >= {} results, got {} (description: {})",
|
||||
@@ -246,13 +222,10 @@ fn golden_queries_all_pass() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check each expected doc_id is in top max_rank
|
||||
for expected_id in &gq.expected_doc_ids {
|
||||
let position = filtered_ids.iter().position(|id| id == expected_id);
|
||||
match position {
|
||||
Some(pos) if pos < gq.max_rank => {
|
||||
// Pass
|
||||
}
|
||||
Some(pos) if pos < gq.max_rank => {}
|
||||
Some(pos) => {
|
||||
failures.push(format!(
|
||||
"FAIL [{}] \"{}\": expected doc_id {} in top {}, found at rank {} (description: {})",
|
||||
|
||||
Reference in New Issue
Block a user