vibe-tests 0.0.1

Integration test framework for MCP servers with LLM-powered tool calling.
Documentation
//! Test framework error types.

/// Errors that can occur during MCP testing.
#[derive(Debug)]
pub enum TestError {
    /// I/O error reading or writing file.
    Io(std::io::Error),
    /// Environment setup failed (OpenSearch, MCP server).
    Setup(String),
    /// MCP tool call failed or returned error.
    ToolCall(ToolCallError),
    /// Ollama API request failed.
    Ollama(String),
    /// Timeout waiting for service to become ready.
    Timeout(String),
}

/// MCP tool call error details.
#[derive(Debug)]
pub struct ToolCallError {
    /// Tool called by the model (None if no tool was called).
    pub tool: Option<String>,
    /// Arguments passed to the tool (None if no tool was called).
    pub args: Option<String>,
    /// MCP error code (e.g. -32602 for invalid params).
    pub code: i32,
}

/// Human-readable error message for each variant.
impl std::fmt::Display for TestError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            TestError::Io(e) => write!(f, "I/O error: {}", e),
            TestError::Setup(e) => write!(f, "Setup error: {}", e),
            TestError::ToolCall(e) => write!(f, "Tool call error: {:?}", e),
            TestError::Ollama(e) => write!(f, "Ollama error: {}", e),
            TestError::Timeout(e) => write!(f, "Timeout: {}", e),
        }
    }
}

/// Chain the underlying I/O error as the source.
impl std::error::Error for TestError {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            TestError::Io(e) => Some(e),
            _ => None,
        }
    }
}

/// Auto-convert I/O errors into TestError::Io.
impl From<std::io::Error> for TestError {
    fn from(e: std::io::Error) -> Self {
        TestError::Io(e)
    }
}

/// Result type alias for test operations.
pub type TestsResult<T> = std::result::Result<T, TestError>;