Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Mar 21, 2024
1 parent f35ef04 commit f550483
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rust/agama-server/src/web/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async fn build_service_status_proxy<'a>(
/// ).await.unwrap();
/// let router: Router<HelloWorldState> = Router::new()
/// .route("/hello", get(hello))
/// .merge(progress)
/// .merge(progress_router)
/// .with_state(HelloWorldState {});
/// });
/// ```
Expand Down Expand Up @@ -238,7 +238,7 @@ async fn build_progress_proxy<'a>(
/// ```no_run
/// # use axum::{extract::State, routing::get, Json, Router};
/// # use agama_lib::connection;
/// # use agama_server::web::common::service_status_router;
/// # use agama_server::web::common::{issues_router, service_status_router};
/// # use tokio_test;
///
/// # tokio_test::block_on(async {
Expand Down
23 changes: 19 additions & 4 deletions rust/agama-server/tests/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use agama_lib::network::{
};
use agama_server::network::{
self,
model::{self, Ipv4Method, Ipv6Method},
model::{self, GeneralState, Ipv4Method, Ipv6Method, NetworkStateItems},
Adapter, NetworkAdapterError, NetworkService, NetworkState,
};
use async_trait::async_trait;
Expand All @@ -21,7 +21,10 @@ pub struct NetworkTestAdapter(network::NetworkState);

#[async_trait]
impl Adapter for NetworkTestAdapter {
async fn read(&self) -> Result<network::NetworkState, NetworkAdapterError> {
async fn read(
&self,
_: Vec<NetworkStateItems>,
) -> Result<network::NetworkState, NetworkAdapterError> {
Ok(self.0.clone())
}

Expand All @@ -34,12 +37,18 @@ impl Adapter for NetworkTestAdapter {
async fn test_read_connections() -> Result<(), Box<dyn Error>> {
let mut server = DBusServer::new().start().await?;

let general_state = GeneralState {
wireless_enabled: false,
connectivity: true,
networking_enabled: true,
};

let device = model::Device {
name: String::from("eth0"),
type_: DeviceType::Ethernet,
};
let eth0 = model::Connection::new("eth0".to_string(), DeviceType::Ethernet);
let state = NetworkState::new(vec![device], vec![eth0]);
let state = NetworkState::new(general_state, vec![], vec![device], vec![eth0]);
let adapter = NetworkTestAdapter(state);

NetworkService::start(&server.connection(), adapter).await?;
Expand Down Expand Up @@ -143,12 +152,18 @@ async fn test_add_bond_connection() -> Result<(), Box<dyn Error>> {
async fn test_update_connection() -> Result<(), Box<dyn Error>> {
let mut server = DBusServer::new().start().await?;

let general_state = GeneralState {
wireless_enabled: false,
connectivity: true,
networking_enabled: true,
};

let device = model::Device {
name: String::from("eth0"),
type_: DeviceType::Ethernet,
};
let eth0 = model::Connection::new("eth0".to_string(), DeviceType::Ethernet);
let state = NetworkState::new(vec![device], vec![eth0]);
let state = NetworkState::new(general_state, vec![], vec![device], vec![eth0]);
let adapter = NetworkTestAdapter(state);

NetworkService::start(&server.connection(), adapter).await?;
Expand Down

0 comments on commit f550483

Please sign in to comment.