Skip to content

Commit 9daab24

Browse files
committed
tests
1 parent 0eeef1e commit 9daab24

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/app_config.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::net::{SocketAddr, ToSocketAddrs};
77
#[cfg(not(feature = "lambda-web"))]
88
const DEFAULT_DATABASE_FILE: &str = "sqlpage.db";
99

10-
#[derive(Debug, Deserialize)]
10+
#[derive(Debug, Deserialize, PartialEq)]
1111
pub struct AppConfig {
1212
#[serde(default = "default_database_url")]
1313
pub database_url: String,
@@ -105,17 +105,14 @@ fn default_database_connection_acquire_timeout_seconds() -> f64 {
105105
#[cfg(test)]
106106
pub(crate) mod tests {
107107
use super::AppConfig;
108-
use std::net::SocketAddr;
109108

110109
pub fn test_config() -> AppConfig {
111-
AppConfig {
112-
database_url: "sqlite::memory:".to_string(),
113-
max_database_pool_connections: None,
114-
database_connection_idle_timeout_seconds: None,
115-
database_connection_max_lifetime_seconds: None,
116-
sqlite_extensions: vec![],
117-
listen_on: SocketAddr::from(([127, 0, 0, 1], 8282)),
118-
port: None,
119-
}
110+
serde_json::from_str::<AppConfig>(
111+
r#"{
112+
"database_url": "sqlite::memory:",
113+
"listen_on": "localhost:8080"
114+
}"#,
115+
)
116+
.unwrap()
120117
}
121118
}

0 commit comments

Comments
 (0)