Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task(tests): introduce prebuilt mocks and mocking helpers #4197

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion crates/matrix-sdk-common/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl SyncTimelineEvent {
/// Get the event id of this `SyncTimelineEvent` if the event has any valid
/// id.
pub fn event_id(&self) -> Option<OwnedEventId> {
self.kind.raw().get_field::<OwnedEventId>("event_id").ok().flatten()
self.kind.event_id()
}

/// Returns a reference to the (potentially decrypted) Matrix event inside
Expand Down Expand Up @@ -529,6 +529,12 @@ impl TimelineEventKind {
}
}

/// Get the event id of this `TimelineEventKind` if the event has any valid
/// id.
pub fn event_id(&self) -> Option<OwnedEventId> {
self.raw().get_field::<OwnedEventId>("event_id").ok().flatten()
}

/// If the event was a decrypted event that was successfully decrypted, get
/// its encryption info. Otherwise, `None`.
pub fn encryption_info(&self) -> Option<&EncryptionInfo> {
Expand Down
4 changes: 4 additions & 0 deletions crates/matrix-sdk/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Testing utilities - DO NOT USE IN PRODUCTION.

#![allow(missing_docs)]
#![allow(dead_code)]

use assert_matches2::assert_let;
Expand All @@ -14,6 +15,9 @@ use url::Url;

pub mod events;

#[cfg(not(target_arch = "wasm32"))]
pub mod mocks;

use crate::{
config::RequestConfig,
matrix_auth::{MatrixSession, MatrixSessionTokens},
Expand Down
2 changes: 0 additions & 2 deletions crates/matrix-sdk/src/test_utils/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![allow(missing_docs)]

use std::sync::atomic::{AtomicU64, Ordering::SeqCst};

use as_variant::as_variant;
Expand Down
Loading
Loading