mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-25 02:06:28 +00:00
warnings
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use serde_derive::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use tokio::fs::File;
|
||||
use tokio::io::AsyncReadExt;
|
||||
use toml;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::errors::Error;
|
||||
|
||||
#[derive(Clone, PartialEq, Hash, std::cmp::Eq, Debug)]
|
||||
@@ -62,16 +62,6 @@ pub async fn parse(path: &str) -> Result<Config, Error> {
|
||||
}
|
||||
};
|
||||
|
||||
// let config: toml::Value = match toml::from_str(&contents) {
|
||||
// Ok(config) => config,
|
||||
// Err(err) => {
|
||||
// println!("> Config error: {:?}", err);
|
||||
// return Err(Error::BadConfig);
|
||||
// }
|
||||
// };
|
||||
|
||||
// println!("Config: {:?}", config);
|
||||
|
||||
let config: Config = match toml::from_str(&contents) {
|
||||
Ok(config) => config,
|
||||
Err(err) => {
|
||||
@@ -82,3 +72,16 @@ pub async fn parse(path: &str) -> Result<Config, Error> {
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_config() {
|
||||
let config = parse("pgcat.toml").await.unwrap();
|
||||
assert_eq!(config.general.pool_size, 15);
|
||||
assert_eq!(config.shards.len(), 3);
|
||||
assert_eq!(config.shards["1"].servers[0].0, "127.0.0.1");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user