mod common;
use dbmcp_config::{Config, DatabaseBackend, DatabaseConfig, PiiConfig};
use dbmcp_server::Server;
use dbmcp_sqlite::SqliteHandler;
fn server(read_only: bool) -> Server {
let config = Config {
database: DatabaseConfig {
backend: DatabaseBackend::Sqlite,
name: Some(std::env::var("DB_PATH").expect("DB_PATH must be set")),
read_only,
..DatabaseConfig::default()
},
http: None,
pii: PiiConfig::default(),
};
SqliteHandler::new(&config).expect("handler builds").into()
}
#[tokio::test]
async fn test_server_info_read_write() {
common::run_with_client(server(false), |peer| async move {
let info = peer.peer_info().expect("missing peer_info");
insta::assert_json_snapshot!("server_info_read_write", info, {
".serverInfo.version" => "[version]"
});
})
.await;
}
#[tokio::test]
async fn test_server_info_read_only() {
common::run_with_client(server(true), |peer| async move {
let info = peer.peer_info().expect("missing peer_info");
insta::assert_json_snapshot!("server_info_read_only", info, {
".serverInfo.version" => "[version]"
});
})
.await;
}
#[tokio::test]
async fn test_list_tools_read_write() {
common::run_with_client(server(false), |peer| async move {
let tools = peer.list_all_tools().await.expect("list_all_tools failed");
insta::assert_json_snapshot!("list_tools_read_write", tools);
})
.await;
}
#[tokio::test]
async fn test_list_tools_read_only() {
common::run_with_client(server(true), |peer| async move {
let tools = peer.list_all_tools().await.expect("list_all_tools failed");
insta::assert_json_snapshot!("list_tools_read_only", tools);
})
.await;
}