Struct autopush_common::db::client::MockDbClient

source ·
pub struct MockDbClient { /* private fields */ }
Expand description

Provides high-level operations for data management.

This is usually manifested by database::DbClientImpl

Implementations§

source§

impl MockDbClient

source

pub fn checkpoint(&mut self)

Validate that all current expectations for all methods have been satisfied, and discard them.

source

pub fn new() -> Self

Create a new mock object with no expectations.

This method will not be generated if the real struct already has a new method. However, it will be generated if the struct implements a trait with a new method. The trait’s new method can still be called like <MockX as TraitY>::new

source§

impl MockDbClient

source

pub fn expect_add_user(&mut self) -> &mut Expectation

Create an Expectation for mocking the add_user method

source

pub fn expect_update_user(&mut self) -> &mut Expectation

Create an Expectation for mocking the update_user method

source

pub fn expect_get_user(&mut self) -> &mut Expectation

Create an Expectation for mocking the get_user method

source

pub fn expect_remove_user(&mut self) -> &mut Expectation

Create an Expectation for mocking the remove_user method

source

pub fn expect_add_channel(&mut self) -> &mut Expectation

Create an Expectation for mocking the add_channel method

source

pub fn expect_add_channels(&mut self) -> &mut Expectation

Create an Expectation for mocking the add_channels method

source

pub fn expect_get_channels(&mut self) -> &mut Expectation

Create an Expectation for mocking the get_channels method

source

pub fn expect_remove_channel(&mut self) -> &mut Expectation

Create an Expectation for mocking the remove_channel method

source

pub fn expect_remove_node_id(&mut self) -> &mut Expectation

Create an Expectation for mocking the remove_node_id method

source

pub fn expect_save_message(&mut self) -> &mut Expectation

Create an Expectation for mocking the save_message method

source

pub fn expect_save_messages(&mut self) -> &mut Expectation

Create an Expectation for mocking the save_messages method

source

pub fn expect_fetch_topic_messages(&mut self) -> &mut Expectation

Create an Expectation for mocking the fetch_topic_messages method

source

pub fn expect_fetch_timestamp_messages(&mut self) -> &mut Expectation

Create an Expectation for mocking the fetch_timestamp_messages method

source

pub fn expect_increment_storage(&mut self) -> &mut Expectation

Create an Expectation for mocking the increment_storage method

source

pub fn expect_remove_message(&mut self) -> &mut Expectation

Create an Expectation for mocking the remove_message method

source

pub fn expect_router_table_exists(&mut self) -> &mut Expectation

Create an Expectation for mocking the router_table_exists method

source

pub fn expect_message_table_exists(&mut self) -> &mut Expectation

Create an Expectation for mocking the message_table_exists method

source

pub fn expect_health_check(&mut self) -> &mut Expectation

Create an Expectation for mocking the health_check method

source

pub fn expect_name(&mut self) -> &mut Expectation

Create an Expectation for mocking the name method

source

pub fn expect_pool_status(&mut self) -> &mut Expectation

Create an Expectation for mocking the pool_status method

source

pub fn expect_box_clone(&mut self) -> &mut Expectation

Create an Expectation for mocking the box_clone method

source§

impl MockDbClient

source

pub fn into_boxed_arc(self) -> Box<Arc<Self>>

Convert into a type which can be used in place of Box<dyn DbClient>. Arc is used so that the mock can be cloned. Box is used so it can be easily cast to Box<dyn DbClient>.

Trait Implementations§

source§

impl DbClient for MockDbClient

Provides high-level operations for data management.

This is usually manifested by database::DbClientImpl

source§

fn add_user<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 User, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add a new user to the database. An error will occur if the user already exists.

source§

fn update_user<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 mut User, ) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update a user in the database. Returns whether the update occurred. The update will not occur if the user does not already exist, has a different router type, or has a newer connected_at timestamp.

source§

fn get_user<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = DbResult<Option<User>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a user from the database

source§

fn remove_user<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a user from the router table

source§

fn add_channel<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, channel_id: &'life2 Uuid, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Add a channel to a user

source§

fn add_channels<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, channels: HashSet<Uuid>, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add a batch of channels to a user

source§

fn get_channels<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = DbResult<HashSet<Uuid>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the set of channel IDs for a user

source§

fn remove_channel<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, channel_id: &'life2 Uuid, ) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Remove a channel from a user. Returns if the removed channel did exist.

source§

fn remove_node_id<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, node_id: &'life2 str, connected_at: u64, version: &'life3 Option<Uuid>, ) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remove the node ID from a user in the router table. Returns whether the removal occurred. The node ID will only be removed if connected_at matches up with the item’s connected_at.

source§

fn save_message<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, message: Notification, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save a message to the message table

source§

fn save_messages<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, messages: Vec<Notification>, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save multiple messages to the message table

source§

fn fetch_topic_messages<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, limit: usize, ) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch stored messages for a user

source§

fn fetch_timestamp_messages<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, timestamp: Option<u64>, limit: usize, ) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch stored messages later than a given

source§

fn increment_storage<'life0, 'life1, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, timestamp: u64, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update the last read timestamp for a user

source§

fn remove_message<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, uaid: &'life1 Uuid, sort_key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete a notification

source§

fn router_table_exists<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the router table exists

source§

fn message_table_exists<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the message table exists

source§

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform the health check on this data store

source§

fn name(&self) -> String

Provide the module name. This was added for simple dual mode testing (legacy), but may be useful in other situations.

source§

fn pool_status(&self) -> Option<Status>

Return the current deadpool Status (if using deadpool)

source§

fn box_clone(&self) -> Box<dyn DbClient>

source§

impl Debug for MockDbClient

source§

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

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

impl Default for MockDbClient

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
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,