// SPDX-FileCopyrightText: Politik im Blick developers
// SPDX-FileCopyrightText: Wolfgang Silbermayr <wolfgang@silbermayr.at>
//
// SPDX-License-Identifier: AGPL-3.0-or-later OR EUPL-1.2

use std::sync::Arc;

use pib_service_inventory::{Inventory, InventoryProvider, MockInventory, MockInventoryProvider};
use tokio::sync::RwLock;

pub fn mock_inventory_with_provider() -> (Arc<RwLock<MockInventory>>, Arc<dyn InventoryProvider>) {
    let inventory = Arc::new(RwLock::new(MockInventory::new()));

    let mut provider = MockInventoryProvider::new();
    {
        let inventory: Box<dyn Inventory> = Box::new(inventory.clone());
        provider
            .expect_get_inventory()
            .return_once(move || Ok(inventory));
    }

    (inventory, Arc::new(provider))
}
