Private
Public Access
1
0

proj: Fix warnings

This commit is contained in:
2025-01-20 22:13:44 -08:00
parent 5d3d2f194a
commit bfc6fdddc1
5 changed files with 15 additions and 7 deletions

View File

@@ -1,7 +1,6 @@
use anyhow::Result; use anyhow::Result;
use diesel::{prelude::*, sqlite::Sqlite}; use diesel::prelude::*;
use diesel::query_dsl::BelongingToDsl; use diesel::query_dsl::BelongingToDsl;
use std::path::{Path, PathBuf};
use crate::models::Participant; use crate::models::Participant;
use crate::{ use crate::{

View File

@@ -1,8 +1,7 @@
extern crate hyper; extern crate hyper;
extern crate serde; extern crate serde;
use std::{ffi::OsString, path::PathBuf, str}; use std::{path::PathBuf, str};
use log::{error};
use hyper::{Body, Client, Method, Request, Uri}; use hyper::{Body, Client, Method, Request, Uri};
@@ -76,10 +75,13 @@ impl AuthBuilder for hyper::http::request::Builder {
} }
} }
#[cfg(test)]
#[allow(dead_code)]
trait AuthSetting { trait AuthSetting {
fn authenticate(&mut self, token: &Option<JwtToken>); fn authenticate(&mut self, token: &Option<JwtToken>);
} }
#[cfg(test)]
impl<B> AuthSetting for hyper::http::Request<B> { impl<B> AuthSetting for hyper::http::Request<B> {
fn authenticate(&mut self, token: &Option<JwtToken>) { fn authenticate(&mut self, token: &Option<JwtToken>) {
if let Some(token) = &token { if let Some(token) = &token {
@@ -221,9 +223,11 @@ impl HTTPAPIClient {
} }
} }
#[cfg(test)]
mod test { mod test {
use super::*; use super::*;
#[cfg(test)]
fn local_mock_client() -> HTTPAPIClient { fn local_mock_client() -> HTTPAPIClient {
let base_url = "http://localhost:5738".parse().unwrap(); let base_url = "http://localhost:5738".parse().unwrap();
let credentials = Credentials { let credentials = Credentials {
@@ -234,6 +238,7 @@ mod test {
HTTPAPIClient::new(base_url, credentials.into()) HTTPAPIClient::new(base_url, credentials.into())
} }
#[cfg(test)]
async fn mock_client_is_reachable() -> bool { async fn mock_client_is_reachable() -> bool {
let mut client = local_mock_client(); let mut client = local_mock_client();
let version = client.get_version().await; let version = client.get_version().await;
@@ -241,7 +246,7 @@ mod test {
match version { match version {
Ok(_) => true, Ok(_) => true,
Err(e) => { Err(e) => {
error!("Mock client error: {:?}", e); log::error!("Mock client error: {:?}", e);
false false
} }
} }

View File

@@ -10,18 +10,21 @@ use hyper::http::HeaderValue;
use serde::Deserialize; use serde::Deserialize;
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
#[allow(dead_code)]
struct JwtHeader { struct JwtHeader {
alg: String, alg: String,
typ: String, typ: String,
} }
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
#[allow(dead_code)]
enum ExpValue { enum ExpValue {
Integer(i64), Integer(i64),
String(String), String(String),
} }
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
#[allow(dead_code)]
struct JwtPayload { struct JwtPayload {
exp: serde_json::Value, exp: serde_json::Value,
iss: Option<String>, iss: Option<String>,
@@ -29,6 +32,7 @@ struct JwtPayload {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct JwtToken { pub struct JwtToken {
header: JwtHeader, header: JwtHeader,
payload: JwtPayload, payload: JwtPayload,

View File

@@ -4,7 +4,7 @@ use std::collections::HashMap;
pub use crate::APIInterface; pub use crate::APIInterface;
use crate::{ use crate::{
api::http_client::Credentials, api::http_client::Credentials,
model::{conversation, Conversation, ConversationID, JwtToken, Message} model::{Conversation, ConversationID, JwtToken, Message}
}; };
pub struct TestClient { pub struct TestClient {

View File

@@ -1,7 +1,7 @@
use anyhow::Result; use anyhow::Result;
use clap::Subcommand; use clap::Subcommand;
use kordophone::APIInterface; use kordophone::APIInterface;
use std::{env, path::{Path, PathBuf}}; use std::{env, path::PathBuf};
use kordophone_db::ChatDatabase; use kordophone_db::ChatDatabase;
use crate::{client, printers::ConversationPrinter}; use crate::{client, printers::ConversationPrinter};