MockAurApi

Struct MockAurApi 

Source
pub struct MockAurApi { /* private fields */ }
Expand description

What: Mock implementation of AurApi for testing.

Inputs: None (created via MockAurApi::new() or builder methods)

Output:

  • MockAurApi instance 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

Source

pub fn new() -> Self

What: Create a new MockAurApi with empty configuration.

Inputs: None

Output:

  • MockAurApi instance ready for configuration

Details:

  • Starts with no predefined results
  • Use builder methods to configure responses
Source

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 match
  • results: Result containing search results

Output:

  • Self for 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)
Source

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:

  • Self for method chaining

Details:

  • Used when a query doesn’t have a specific match
  • If not set, returns an error for unmatched queries
Source

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 names
  • result: Result containing package details

Output:

  • Self for 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)
Source

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:

  • Self for method chaining
Source

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 name
  • result: Result containing comments

Output:

  • Self for method chaining
§Panics
  • Panics if the internal mutex is poisoned (should never happen in practice)
Source

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:

  • Self for method chaining
Source

pub fn with_pkgbuild_result(self, package: &str, result: Result<String>) -> Self

What: Set a pkgbuild result for a specific package.

Inputs:

  • package: Package name
  • result: Result containing PKGBUILD content

Output:

  • Self for method chaining
§Panics
  • Panics if the internal mutex is poisoned (should never happen in practice)
Source

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:

  • Self for method chaining

Trait Implementations§

Source§

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,

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,

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,

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,

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
Source§

impl Debug for MockAurApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MockAurApi

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more