#![allow(dead_code)]
const TEST_POOL_LABEL: &str = "test-pool";
const TEST_CONT_LABEL: &str = "test-container";
const TEST_OBJ_ID: u64 = 0xdeadbeef_cafebabe;
#[cfg(feature = "mock")]
mod mock_tests {
#![allow(dead_code)]
use super::*;
#[test]
fn test_mock_runtime_fixture() {
let runtime = MockRuntime::new();
assert!(!runtime.is_initialized());
}
#[test]
fn test_test_pool_fixture() {
let pool = TestPool::new(TEST_POOL_LABEL);
assert_eq!(pool.label, TEST_POOL_LABEL);
}
#[test]
fn test_test_container_fixture() {
let cont = TestContainer::new(TEST_CONT_LABEL);
assert_eq!(cont.label, TEST_CONT_LABEL);
}
use mockall::automock;
#[automock]
trait DaosRuntimeTrait {
fn init(&self) -> daoxide::error::Result<()>;
fn fini(&self) -> daoxide::error::Result<()>;
}
#[derive(Debug, Clone, Default)]
struct MockRuntime {
initialized: bool,
}
impl MockRuntime {
fn new() -> Self {
Self { initialized: false }
}
fn is_initialized(&self) -> bool {
self.initialized
}
}
#[derive(Debug, Clone, Default)]
struct TestPool {
label: String,
uuid: Option<uuid::Uuid>,
}
impl TestPool {
fn new(label: impl Into<String>) -> Self {
Self {
label: label.into(),
uuid: None,
}
}
fn with_uuid(mut self, uuid: uuid::Uuid) -> Self {
self.uuid = Some(uuid);
self
}
}
#[derive(Debug, Clone, Default)]
struct TestContainer {
label: String,
uuid: Option<uuid::Uuid>,
}
impl TestContainer {
fn new(label: impl Into<String>) -> Self {
Self {
label: label.into(),
uuid: None,
}
}
}
}
#[test]
fn test_error_type_exists() {
let _err = daoxide::DaosError::InvalidArg;
}
#[test]
fn test_runtime_struct_exists() {
let runtime = daoxide::runtime::DaosRuntime::new();
assert!(runtime.is_ok());
}
#[test]
fn test_pool_struct_exists() {
use std::any::type_name;
let name = type_name::<daoxide::pool::Pool>();
assert!(name.contains("Pool"));
}
#[test]
fn test_container_struct_exists() {
use std::any::type_name;
let name = type_name::<daoxide::container::Container<'static>>();
assert!(name.contains("Container"));
}
#[test]
fn test_object_struct_exists() {
use std::any::type_name;
let name = type_name::<daoxide::object::Object>();
assert!(name.contains("Object"));
}
#[test]
fn test_transaction_struct_exists() {
use std::any::type_name;
let name = type_name::<daoxide::tx::Transaction<'static>>();
assert!(name.contains("Transaction"));
}
#[test]
fn test_result_type_alias() {
fn accept_result<T>(_: daoxide::error::Result<T>) {}
accept_result::<()>(Ok(()));
}