refactor to work as a lib
This commit is contained in:
20
tests/test_config.rs
Normal file
20
tests/test_config.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use dns_config;
|
||||
|
||||
#[test]
|
||||
fn test_config() {
|
||||
let zone_data =
|
||||
dns_config::ServerZonesConnection::get_config(&"config_template.toml".to_string()).unwrap();
|
||||
assert_eq!(zone_data.root_domain, "root.domain.example");
|
||||
assert_eq!(
|
||||
zone_data.servers_data.get(1).unwrap().conection_str,
|
||||
"udp://192.168.1.1:53"
|
||||
);
|
||||
assert_eq!(
|
||||
zone_data.servers_data.get(0).unwrap().key,
|
||||
"key 0 in base64"
|
||||
);
|
||||
assert_eq!(
|
||||
zone_data.servers_data.get(1).unwrap().key_name,
|
||||
"key 1 name"
|
||||
);
|
||||
}
|
||||
27
tests/test_management.rs
Normal file
27
tests/test_management.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use std::{net::Ipv4Addr, str::FromStr};
|
||||
|
||||
use dns_comunications::DnsManager;
|
||||
|
||||
fn get_manager() -> DnsManager {
|
||||
dns_comunications::DnsManager::new(
|
||||
dns_config::ServerZonesConnection::get_config(&"config.toml".to_string()).unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_creating_zone() {
|
||||
let res = get_manager()
|
||||
.add_domain(
|
||||
&"testzone".to_string(),
|
||||
Ipv4Addr::from_str("1.1.1.1").unwrap(),
|
||||
)
|
||||
.await;
|
||||
assert!(res.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_deleting_zone() {
|
||||
let res = get_manager().del_domain(&"testzone".to_string()).await;
|
||||
assert!(res.is_ok());
|
||||
}
|
||||
Reference in New Issue
Block a user