mirror of
https://github.com/thegeneralist01/archivr
synced 2026-05-30 08:36:47 +02:00
Gate test-only database helpers behind cfg(test)
This commit is contained in:
parent
5fae7c71af
commit
b712bdd5db
1 changed files with 8 additions and 8 deletions
|
|
@ -484,7 +484,7 @@ pub fn add_entry_artifact(conn: &Connection, artifact: &NewArtifact) -> Result<i
|
||||||
Ok(conn.last_insert_rowid())
|
Ok(conn.last_insert_rowid())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub fn set_public_settings(
|
pub fn set_public_settings(
|
||||||
conn: &Connection,
|
conn: &Connection,
|
||||||
public_index_enabled: bool,
|
public_index_enabled: bool,
|
||||||
|
|
@ -506,7 +506,7 @@ pub fn set_public_settings(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub fn public_index_entry_count(conn: &Connection) -> Result<i64> {
|
pub fn public_index_entry_count(conn: &Connection) -> Result<i64> {
|
||||||
let count = conn.query_row(
|
let count = conn.query_row(
|
||||||
"SELECT COUNT(*)
|
"SELECT COUNT(*)
|
||||||
|
|
@ -521,7 +521,7 @@ pub fn public_index_entry_count(conn: &Connection) -> Result<i64> {
|
||||||
Ok(count)
|
Ok(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub fn main_archive_entry_count(conn: &Connection) -> Result<i64> {
|
pub fn main_archive_entry_count(conn: &Connection) -> Result<i64> {
|
||||||
let count = conn.query_row(
|
let count = conn.query_row(
|
||||||
"SELECT COUNT(*) FROM archived_entries WHERE parent_entry_id IS NULL",
|
"SELECT COUNT(*) FROM archived_entries WHERE parent_entry_id IS NULL",
|
||||||
|
|
@ -531,7 +531,7 @@ pub fn main_archive_entry_count(conn: &Connection) -> Result<i64> {
|
||||||
Ok(count)
|
Ok(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub fn create_taxonomy_path(conn: &Connection, full_path: &str) -> Result<i64> {
|
pub fn create_taxonomy_path(conn: &Connection, full_path: &str) -> Result<i64> {
|
||||||
let segments = normalized_taxonomy_segments(full_path)?;
|
let segments = normalized_taxonomy_segments(full_path)?;
|
||||||
let mut parent_id = None;
|
let mut parent_id = None;
|
||||||
|
|
@ -573,7 +573,7 @@ pub fn create_taxonomy_path(conn: &Connection, full_path: &str) -> Result<i64> {
|
||||||
Ok(current_id)
|
Ok(current_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub fn assign_entry_to_taxonomy(conn: &Connection, entry_id: i64, node_id: i64) -> Result<()> {
|
pub fn assign_entry_to_taxonomy(conn: &Connection, entry_id: i64, node_id: i64) -> Result<()> {
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT OR IGNORE INTO entry_taxonomy_assignments (entry_id, node_id)
|
"INSERT OR IGNORE INTO entry_taxonomy_assignments (entry_id, node_id)
|
||||||
|
|
@ -583,7 +583,7 @@ pub fn assign_entry_to_taxonomy(conn: &Connection, entry_id: i64, node_id: i64)
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
pub fn entry_count_for_taxonomy_path(conn: &Connection, full_path: &str) -> Result<i64> {
|
pub fn entry_count_for_taxonomy_path(conn: &Connection, full_path: &str) -> Result<i64> {
|
||||||
let count = conn.query_row(
|
let count = conn.query_row(
|
||||||
"WITH RECURSIVE descendants(id) AS (
|
"WITH RECURSIVE descendants(id) AS (
|
||||||
|
|
@ -649,7 +649,7 @@ fn validate_visibility(visibility: &str) -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
fn normalized_taxonomy_segments(full_path: &str) -> Result<Vec<&str>> {
|
fn normalized_taxonomy_segments(full_path: &str) -> Result<Vec<&str>> {
|
||||||
let segments = full_path
|
let segments = full_path
|
||||||
.trim()
|
.trim()
|
||||||
|
|
@ -665,7 +665,7 @@ fn normalized_taxonomy_segments(full_path: &str) -> Result<Vec<&str>> {
|
||||||
Ok(segments)
|
Ok(segments)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[cfg(test)]
|
||||||
fn humanize_slug(slug: &str) -> String {
|
fn humanize_slug(slug: &str) -> String {
|
||||||
slug.split('-')
|
slug.split('-')
|
||||||
.map(|part| {
|
.map(|part| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue