clean up warnings

This commit is contained in:
Joseph Montanaro 2024-07-11 06:04:56 -04:00
parent a32e36be7e
commit 5cf848f7fe
4 changed files with 32 additions and 43 deletions

View File

@ -203,19 +203,6 @@ mod tests {
)
}
fn test_uuid() -> Uuid {
Uuid::try_parse("00000000-0000-0000-0000-000000000000").unwrap()
}
fn test_uuid_2() -> Uuid {
Uuid::try_parse("ffffffff-ffff-ffff-ffff-ffffffffffff").unwrap()
}
fn test_uuid_random() -> Uuid {
let bytes = Crypto::salt();
Uuid::from_slice(&bytes[..16]).unwrap()
}
#[sqlx::test(fixtures("aws_credentials"))]
async fn test_load(pool: SqlitePool) {

View File

@ -112,15 +112,16 @@ impl CredentialRecord {
Ok(Self::from_parts(row, credential))
}
// pub async fn load(id: &Uuid, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> {
// let row: CredentialRow = sqlx::query_as("SELECT * FROM credentials WHERE id = ?")
// .bind(id)
// .fetch_optional(pool)
// .await?
// .ok_or(LoadCredentialsError::NoCredentials)?;
#[cfg(test)]
pub async fn load(id: &Uuid, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> {
let row: CredentialRow = sqlx::query_as("SELECT * FROM credentials WHERE id = ?")
.bind(id)
.fetch_optional(pool)
.await?
.ok_or(LoadCredentialsError::NoCredentials)?;
// Self::load_credential(row, crypto, pool).await
// }
Self::load_credential(row, crypto, pool).await
}
pub async fn load_by_name(name: &str, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> {
let row: CredentialRow = sqlx::query_as("SELECT * FROM credentials WHERE name = ?")

View File

@ -298,7 +298,6 @@ fn deserialize_algorithm<'de, D>(deserializer: D) -> Result<Algorithm, D::Error>
#[cfg(test)]
mod tests {
use std::fs::{self, File};
use ssh_key::Fingerprint;
use sqlx::types::uuid::uuid;
use super::*;
@ -447,7 +446,7 @@ mod tests {
async fn test_load_db(pool: SqlitePool) {
let crypto = Crypto::fixed();
let id = uuid!("11111111-1111-1111-1111-111111111111");
let k = SshKey::load(&id, &crypto, &pool).await
SshKey::load(&id, &crypto, &pool).await
.expect("Failed to load SSH key from database");
}

View File

@ -44,12 +44,14 @@ pub async fn load_bytes(pool: &SqlitePool, name: &str) -> Result<Option<Vec<u8>>
}
// pub async fn delete(pool: &SqlitePool, name: &str) -> Result<(), sqlx::Error> {
// sqlx::query!("DELETE FROM kv WHERE name = ?", name)
// .execute(pool)
// .await?;
// Ok(())
// }
// we don't have a need for this right now, but we will some day
#[cfg(test)]
pub async fn delete(pool: &SqlitePool, name: &str) -> Result<(), sqlx::Error> {
sqlx::query!("DELETE FROM kv WHERE name = ?", name)
.execute(pool)
.await?;
Ok(())
}
pub async fn delete_multi(pool: &SqlitePool, names: &[&str]) -> Result<(), sqlx::Error> {