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 4ea2a52
Showing 1 changed file with 19 additions and 4 deletions.
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,
items: 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 4ea2a52

Please sign in to comment.