test(db): cover zero-label term and duplicate vocabulary key; use try_get in vocabulary_by_key

This commit is contained in:
2026-06-02 08:52:58 +02:00
parent 5dc07ddf4c
commit 345073b130
2 changed files with 50 additions and 4 deletions
+8 -4
View File
@@ -39,10 +39,7 @@ where
.fetch_optional(executor)
.await?;
Ok(row.map(|r| Vocabulary {
id: VocabularyId::from_uuid(r.get("id")),
key: r.get("key"),
}))
row.map(map_vocabulary).transpose()
}
/// Insert a term and its labels. Multiple statements — pass a transaction
@@ -129,6 +126,13 @@ where
Ok(found.map(|_| TermRef::new(term_id, vocabulary_id)))
}
fn map_vocabulary(row: sqlx::postgres::PgRow) -> Result<Vocabulary, sqlx::Error> {
Ok(Vocabulary {
id: VocabularyId::from_uuid(row.try_get("id")?),
key: row.try_get("key")?,
})
}
fn map_term(row: sqlx::postgres::PgRow) -> Result<Term, sqlx::Error> {
let labels: sqlx::types::Json<Vec<LocalizedLabel>> = row.try_get("labels")?;