diff --git a/kordophone-db/src/chat_database.rs b/kordophone-db/src/chat_database.rs index 1e310fb..e4d55c8 100644 --- a/kordophone-db/src/chat_database.rs +++ b/kordophone-db/src/chat_database.rs @@ -1,7 +1,6 @@ use anyhow::Result; -use diesel::{prelude::*, sqlite::Sqlite}; +use diesel::prelude::*; use diesel::query_dsl::BelongingToDsl; -use std::path::{Path, PathBuf}; use crate::models::Participant; use crate::{ diff --git a/kordophone/src/api/http_client.rs b/kordophone/src/api/http_client.rs index c1e8def..024b44d 100644 --- a/kordophone/src/api/http_client.rs +++ b/kordophone/src/api/http_client.rs @@ -1,8 +1,7 @@ extern crate hyper; extern crate serde; -use std::{ffi::OsString, path::PathBuf, str}; -use log::{error}; +use std::{path::PathBuf, str}; 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 { fn authenticate(&mut self, token: &Option); } +#[cfg(test)] impl AuthSetting for hyper::http::Request { fn authenticate(&mut self, token: &Option) { if let Some(token) = &token { @@ -221,9 +223,11 @@ impl HTTPAPIClient { } } +#[cfg(test)] mod test { use super::*; + #[cfg(test)] fn local_mock_client() -> HTTPAPIClient { let base_url = "http://localhost:5738".parse().unwrap(); let credentials = Credentials { @@ -234,6 +238,7 @@ mod test { HTTPAPIClient::new(base_url, credentials.into()) } + #[cfg(test)] async fn mock_client_is_reachable() -> bool { let mut client = local_mock_client(); let version = client.get_version().await; @@ -241,7 +246,7 @@ mod test { match version { Ok(_) => true, Err(e) => { - error!("Mock client error: {:?}", e); + log::error!("Mock client error: {:?}", e); false } } diff --git a/kordophone/src/model/jwt.rs b/kordophone/src/model/jwt.rs index b5b62b9..70c86e6 100644 --- a/kordophone/src/model/jwt.rs +++ b/kordophone/src/model/jwt.rs @@ -10,18 +10,21 @@ use hyper::http::HeaderValue; use serde::Deserialize; #[derive(Deserialize, Debug, Clone)] +#[allow(dead_code)] struct JwtHeader { alg: String, typ: String, } #[derive(Deserialize, Debug, Clone)] +#[allow(dead_code)] enum ExpValue { Integer(i64), String(String), } #[derive(Deserialize, Debug, Clone)] +#[allow(dead_code)] struct JwtPayload { exp: serde_json::Value, iss: Option, @@ -29,6 +32,7 @@ struct JwtPayload { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct JwtToken { header: JwtHeader, payload: JwtPayload, diff --git a/kordophone/src/tests/test_client.rs b/kordophone/src/tests/test_client.rs index 9af75b5..a67612b 100644 --- a/kordophone/src/tests/test_client.rs +++ b/kordophone/src/tests/test_client.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; pub use crate::APIInterface; use crate::{ api::http_client::Credentials, - model::{conversation, Conversation, ConversationID, JwtToken, Message} + model::{Conversation, ConversationID, JwtToken, Message} }; pub struct TestClient { diff --git a/kpcli/src/db/mod.rs b/kpcli/src/db/mod.rs index 36b68ea..471f6a2 100644 --- a/kpcli/src/db/mod.rs +++ b/kpcli/src/db/mod.rs @@ -1,7 +1,7 @@ use anyhow::Result; use clap::Subcommand; use kordophone::APIInterface; -use std::{env, path::{Path, PathBuf}}; +use std::{env, path::PathBuf}; use kordophone_db::ChatDatabase; use crate::{client, printers::ConversationPrinter};