Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jan 22, 2024
1 parent 1b95066 commit 7011881
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/config/nc.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::config::PartialConfig;
use crate::error::ConfigError;
use nextcloud_config_parser::{parse, parse_glob};
use sqlx_oldapi::any::AnyConnectOptions;
use std::path::Path;
use std::str::FromStr;

pub(super) fn parse_config_file(
path: impl AsRef<Path>,
Expand All @@ -12,7 +10,7 @@ pub(super) fn parse_config_file(
let config = if glob { parse_glob(path) } else { parse(path) }?;

Ok(PartialConfig {
database: Some(AnyConnectOptions::from_str(&config.database.url())?),
database: Some(config.database.url().parse()?),
database_prefix: Some(config.database_prefix),
nextcloud_url: Some(config.nextcloud_url),
redis: config.redis.into_vec(),
Expand Down
2 changes: 1 addition & 1 deletion test_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tungstenite::{connect, Message};
use url::Url;

fn main() -> Result<()> {
Logger::try_with_str(&var("LOG").unwrap_or_else(|_| String::from("test_client=info,warn")))
Logger::try_with_str(var("LOG").unwrap_or_else(|_| String::from("test_client=info,warn")))
.into_diagnostic()?
.adaptive_format_for_stdout(AdaptiveFormat::Detailed)
.adaptive_format_for_stderr(AdaptiveFormat::Detailed)
Expand Down
10 changes: 4 additions & 6 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use redis::AsyncCommands;
use smallvec::alloc::sync::Arc;
use sqlx_oldapi::AnyPool;
use std::net::SocketAddr;
use std::sync::atomic::Ordering;
use std::sync::Mutex;
use std::sync::atomic::{AtomicU16, Ordering};
use tokio::net::{TcpListener, TcpStream};
use tokio::sync::oneshot;
use tokio::task::spawn;
Expand All @@ -25,13 +24,12 @@ use tokio_tungstenite::{MaybeTlsStream, WebSocketStream};
use warp::http::StatusCode;
use warp::{Filter, Reply};

static LAST_PORT: Lazy<Mutex<u16>> = Lazy::new(|| Mutex::new(1024));
static LAST_PORT: AtomicU16 = AtomicU16::new(1024);

async fn listen_available_port() -> Option<TcpListener> {
let mut last_port = LAST_PORT.lock().unwrap();
for port in (*last_port + 1)..65535 {
for _ in LAST_PORT.load(Ordering::SeqCst)..65535 {
let port = LAST_PORT.fetch_add(1, Ordering::SeqCst);
if let Ok(tcp) = TcpListener::bind(("127.0.0.1", port)).await {
*last_port = port;
return Some(tcp);
}
}
Expand Down

0 comments on commit 7011881

Please # to comment.