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"))] #[sqlx::test(fixtures("aws_credentials"))]
async fn test_load(pool: SqlitePool) { async fn test_load(pool: SqlitePool) {

View File

@ -112,15 +112,16 @@ impl CredentialRecord {
Ok(Self::from_parts(row, credential)) Ok(Self::from_parts(row, credential))
} }
// pub async fn load(id: &Uuid, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> { #[cfg(test)]
// let row: CredentialRow = sqlx::query_as("SELECT * FROM credentials WHERE id = ?") pub async fn load(id: &Uuid, crypto: &Crypto, pool: &SqlitePool) -> Result<Self, LoadCredentialsError> {
// .bind(id) let row: CredentialRow = sqlx::query_as("SELECT * FROM credentials WHERE id = ?")
// .fetch_optional(pool) .bind(id)
// .await? .fetch_optional(pool)
// .ok_or(LoadCredentialsError::NoCredentials)?; .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> { 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 = ?") 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)] #[cfg(test)]
mod tests { mod tests {
use std::fs::{self, File}; use std::fs::{self, File};
use ssh_key::Fingerprint;
use sqlx::types::uuid::uuid; use sqlx::types::uuid::uuid;
use super::*; use super::*;
@ -447,7 +446,7 @@ mod tests {
async fn test_load_db(pool: SqlitePool) { async fn test_load_db(pool: SqlitePool) {
let crypto = Crypto::fixed(); let crypto = Crypto::fixed();
let id = uuid!("11111111-1111-1111-1111-111111111111"); 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"); .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> { // we don't have a need for this right now, but we will some day
// sqlx::query!("DELETE FROM kv WHERE name = ?", name) #[cfg(test)]
// .execute(pool) pub async fn delete(pool: &SqlitePool, name: &str) -> Result<(), sqlx::Error> {
// .await?; sqlx::query!("DELETE FROM kv WHERE name = ?", name)
// Ok(()) .execute(pool)
// } .await?;
Ok(())
}
pub async fn delete_multi(pool: &SqlitePool, names: &[&str]) -> Result<(), sqlx::Error> { pub async fn delete_multi(pool: &SqlitePool, names: &[&str]) -> Result<(), sqlx::Error> {