pub struct MockAurApi { /* private fields */ }Expand description
What: Mock implementation of AurApi for testing.
Inputs: None (created via MockAurApi::new() or builder methods)
Output:
MockAurApiinstance that can be configured with predefined responses
Details:
- Allows setting predefined results for each operation type
- Supports both success and error responses
- Thread-safe via
Arc<Mutex<>>for internal state - Builder pattern for easy configuration
- Useful for unit testing without hitting real AUR endpoints
Implementations§
Source§impl MockAurApi
impl MockAurApi
Sourcepub fn new() -> Self
pub fn new() -> Self
What: Create a new MockAurApi with empty configuration.
Inputs: None
Output:
MockAurApiinstance ready for configuration
Details:
- Starts with no predefined results
- Use builder methods to configure responses
Sourcepub fn with_search_result(
self,
query: &str,
result: Result<Vec<AurPackage>>,
) -> Self
pub fn with_search_result( self, query: &str, result: Result<Vec<AurPackage>>, ) -> Self
What: Set a search result for a specific query.
Inputs:
query: Query string to matchresults: Result containing search results
Output:
Selffor method chaining
Details:
- Stores the result for the exact query string
- Overwrites any existing result for this query
§Panics
- Panics if the internal mutex is poisoned (should never happen in practice)
Sourcepub fn with_default_search_result(self, result: Result<Vec<AurPackage>>) -> Self
pub fn with_default_search_result(self, result: Result<Vec<AurPackage>>) -> Self
What: Set a default search result for queries without specific matches.
Inputs:
result: Default result to return
Output:
Selffor method chaining
Details:
- Used when a query doesn’t have a specific match
- If not set, returns an error for unmatched queries
Sourcepub fn with_info_result(
self,
names: &[&str],
result: Result<Vec<AurPackageDetails>>,
) -> Self
pub fn with_info_result( self, names: &[&str], result: Result<Vec<AurPackageDetails>>, ) -> Self
What: Set an info result for specific package names.
Inputs:
names: Slice of package namesresult: Result containing package details
Output:
Selffor method chaining
Details:
- Stores the result keyed by sorted, comma-separated package names
- Overwrites any existing result for these packages
§Panics
- Panics if the internal mutex is poisoned (should never happen in practice)
Sourcepub fn with_default_info_result(
self,
result: Result<Vec<AurPackageDetails>>,
) -> Self
pub fn with_default_info_result( self, result: Result<Vec<AurPackageDetails>>, ) -> Self
What: Set a default info result for packages without specific matches.
Inputs:
result: Default result to return
Output:
Selffor method chaining
Sourcepub fn with_comments_result(
self,
pkgname: &str,
result: Result<Vec<AurComment>>,
) -> Self
pub fn with_comments_result( self, pkgname: &str, result: Result<Vec<AurComment>>, ) -> Self
What: Set a comments result for a specific package.
Inputs:
pkgname: Package nameresult: Result containing comments
Output:
Selffor method chaining
§Panics
- Panics if the internal mutex is poisoned (should never happen in practice)
Sourcepub fn with_default_comments_result(
self,
result: Result<Vec<AurComment>>,
) -> Self
pub fn with_default_comments_result( self, result: Result<Vec<AurComment>>, ) -> Self
What: Set a default comments result for packages without specific matches.
Inputs:
result: Default result to return
Output:
Selffor method chaining
Sourcepub fn with_pkgbuild_result(self, package: &str, result: Result<String>) -> Self
pub fn with_pkgbuild_result(self, package: &str, result: Result<String>) -> Self
What: Set a pkgbuild result for a specific package.
Inputs:
package: Package nameresult: Result containing PKGBUILD content
Output:
Selffor method chaining
§Panics
- Panics if the internal mutex is poisoned (should never happen in practice)
Sourcepub fn with_default_pkgbuild_result(self, result: Result<String>) -> Self
pub fn with_default_pkgbuild_result(self, result: Result<String>) -> Self
What: Set a default pkgbuild result for packages without specific matches.
Inputs:
result: Default result to return
Output:
Selffor method chaining
Trait Implementations§
Source§impl AurApi for MockAurApi
impl AurApi for MockAurApi
Source§fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<AurPackage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<AurPackage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
What: Search for packages in the AUR by name (mock implementation).
Inputs:
query: Search query string
Output:
Result<Vec<AurPackage>>containing predefined search results, or an error
Details:
- Returns predefined result for the query if available
- Falls back to default search result if set
- Returns error if no match found and no default is set
Source§fn info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
names: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<AurPackageDetails>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
names: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<AurPackageDetails>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
What: Fetch detailed information for one or more AUR packages (mock implementation).
Inputs:
names: Slice of package names to fetch info for
Output:
Result<Vec<AurPackageDetails>>containing predefined package details, or an error
Details:
- Returns predefined result for the sorted package names if available
- Falls back to default info result if set
- Returns error if no match found and no default is set
Source§fn comments<'life0, 'life1, 'async_trait>(
&'life0 self,
pkgname: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<AurComment>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn comments<'life0, 'life1, 'async_trait>(
&'life0 self,
pkgname: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<AurComment>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
What: Fetch AUR package comments (mock implementation).
Inputs:
pkgname: Package name to fetch comments for
Output:
Result<Vec<AurComment>>containing predefined comments, or an error
Details:
- Returns predefined result for the package if available
- Falls back to default comments result if set
- Returns error if no match found and no default is set
Source§fn pkgbuild<'life0, 'life1, 'async_trait>(
&'life0 self,
package: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pkgbuild<'life0, 'life1, 'async_trait>(
&'life0 self,
package: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
What: Fetch PKGBUILD content for an AUR package (mock implementation).
Inputs:
package: Package name to fetch PKGBUILD for
Output:
Result<String>containing predefined PKGBUILD content, or an error
Details:
- Returns predefined result for the package if available
- Falls back to default pkgbuild result if set
- Returns error if no match found and no default is set