proj: Fix warnings
This commit is contained in:
@@ -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::{
|
||||
|
||||
@@ -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<JwtToken>);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl<B> AuthSetting for hyper::http::Request<B> {
|
||||
fn authenticate(&mut self, token: &Option<JwtToken>) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String>,
|
||||
@@ -29,6 +32,7 @@ struct JwtPayload {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct JwtToken {
|
||||
header: JwtHeader,
|
||||
payload: JwtPayload,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user