Skip to content

Commit

Permalink
fixup! integration tests: make randomize_username() the default
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Jul 2, 2024
1 parent 12bf48e commit d28348e
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::helpers::TestClientBuilder;

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_invitation_details() -> Result<()> {
let tamatoa = TestClientBuilder::new("tamatoa".to_owned()).use_sqlite().build().await?;
let sebastian = TestClientBuilder::new("sebastian".to_owned()).use_sqlite().build().await?;
let tamatoa = TestClientBuilder::new("tamatoa").use_sqlite().build().await?;
let sebastian = TestClientBuilder::new("sebastian").use_sqlite().build().await?;

let invite = vec![sebastian.user_id().expect("sebastian has a userid!").to_owned()];
// create a room and invite sebastian;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use crate::helpers::TestClientBuilder;
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_toggling_reaction() -> Result<()> {
// Set up sync for user Alice, and create a room.
let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;

let alice_clone = alice.clone();
let alice_sync = spawn(async move {
Expand Down
4 changes: 2 additions & 2 deletions testing/matrix-sdk-integration-testing/src/tests/redaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn sync_once(client: &Client, sync_token: Option<String>) -> Result<String
#[ignore = "Broken since synapse update, see #1069"]
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_redacting_name() -> Result<()> {
let tamatoa = TestClientBuilder::new("tamatoa".to_owned()).use_sqlite().build().await?;
let tamatoa = TestClientBuilder::new("tamatoa").use_sqlite().build().await?;
// create a room
let request = assign!(CreateRoomRequest::new(), {
is_direct: true,
Expand Down Expand Up @@ -99,7 +99,7 @@ async fn test_redacting_name() -> Result<()> {
#[ignore = "Broken since synapse update, see #1069"]
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_redacting_name_static() -> Result<()> {
let tamatoa = TestClientBuilder::new("tamatoa".to_owned()).use_sqlite().build().await?;
let tamatoa = TestClientBuilder::new("tamatoa").use_sqlite().build().await?;
// create a room
let request = assign!(CreateRoomRequest::new(), {
is_direct: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use crate::helpers::TestClientBuilder;

#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_repeated_join_leave() -> Result<()> {
let peter = TestClientBuilder::new("peter".to_owned()).use_sqlite().build().await?;
let peter = TestClientBuilder::new("peter").use_sqlite().build().await?;
// FIXME: Run once with memory, once with SQLite
let karl = TestClientBuilder::new("karl".to_owned()).build().await?;
let karl = TestClientBuilder::new("karl").build().await?;
let karl_id = karl.user_id().expect("karl has a userid!").to_owned();

// Create a room and invite karl.
Expand Down
4 changes: 2 additions & 2 deletions testing/matrix-sdk-integration-testing/src/tests/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::helpers::TestClientBuilder;

#[tokio::test]
async fn test_event_with_context() -> Result<()> {
let bob = TestClientBuilder::new("bob".to_owned()).use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob").use_sqlite().build().await?;

// Spawn sync for bob.
let b = bob.clone();
Expand All @@ -33,7 +33,7 @@ async fn test_event_with_context() -> Result<()> {
}
});

let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;

// Spawn sync for alice too.
let a = alice.clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::helpers::TestClientBuilder;

#[tokio::test(flavor = "multi_thread")]
async fn test_room_directory_search_filter() -> Result<()> {
let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;
let search_string = random_string(32);
for index in 0..25 {
let mut request: CreateRoomRequest = CreateRoomRequest::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ use crate::helpers::TestClientBuilder;

#[tokio::test]
async fn test_left_room() -> Result<()> {
let peter = TestClientBuilder::new("peter".to_owned()).use_sqlite().build().await?;
let steven = TestClientBuilder::new("steven".to_owned()).use_sqlite().build().await?;
let peter = TestClientBuilder::new("peter").use_sqlite().build().await?;
let steven = TestClientBuilder::new("steven").use_sqlite().build().await?;

// Set up sliding sync for Peter.
let sliding_peter = peter
Expand Down Expand Up @@ -131,9 +131,9 @@ async fn test_left_room() -> Result<()> {

#[tokio::test]
async fn test_room_avatar_group_conversation() -> Result<()> {
let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob".to_owned()).use_sqlite().build().await?;
let celine = TestClientBuilder::new("celine".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob").use_sqlite().build().await?;
let celine = TestClientBuilder::new("celine").use_sqlite().build().await?;

// Bob and Celine set their avatars.
bob.account().set_avatar_url(Some(mxc_uri!("mxc://localhost/bob"))).await?;
Expand Down Expand Up @@ -231,9 +231,9 @@ async fn test_joined_user_can_create_push_context_with_room_list_service() -> Re
// send a message, and fake a new "device" by creating another client for
// the same user.

let bob = TestClientBuilder::new("bob".to_owned()).use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob").use_sqlite().build().await?;

let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;

// Set up regular sync for Alice to start with.
let a = alice.clone();
Expand Down Expand Up @@ -365,7 +365,7 @@ impl UpdateObserver {
async fn test_room_notification_count() -> Result<()> {
use tokio::time::timeout;

let bob = TestClientBuilder::new("bob".to_owned()).use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob").use_sqlite().build().await?;

// Spawn sync for bob.
let b = bob.clone();
Expand All @@ -379,7 +379,7 @@ async fn test_room_notification_count() -> Result<()> {
});

// Set up sliding sync for alice.
let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;

spawn({
let sync = alice
Expand Down Expand Up @@ -728,12 +728,9 @@ async fn test_delayed_decryption_latest_event() -> Result<()> {

server.register(Mock::given(AnyMatcher).respond_with(&**CUSTOM_RESPONDER)).await;

let alice = TestClientBuilder::new("alice".to_owned())
.use_sqlite()
.http_proxy(server.uri())
.build()
.await?;
let bob = TestClientBuilder::new("bob".to_owned()).use_sqlite().build().await?;
let alice =
TestClientBuilder::new("alice").use_sqlite().http_proxy(server.uri()).build().await?;
let bob = TestClientBuilder::new("bob").use_sqlite().build().await?;

let alice_sync_service = SyncService::builder(alice.clone()).build().await.unwrap();
alice_sync_service.start().await;
Expand Down Expand Up @@ -854,8 +851,8 @@ async fn test_delayed_decryption_latest_event() -> Result<()> {

#[tokio::test]
async fn test_roominfo_update_deduplication() -> Result<()> {
let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob").use_sqlite().build().await?;

let alice_sync_service = SyncService::builder(alice.clone()).build().await.unwrap();
alice_sync_service.start().await;
Expand Down Expand Up @@ -993,8 +990,8 @@ async fn test_roominfo_update_deduplication() -> Result<()> {

#[tokio::test]
async fn test_room_preview() -> Result<()> {
let alice = TestClientBuilder::new("alice".to_owned()).use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob".to_owned()).use_sqlite().build().await?;
let alice = TestClientBuilder::new("alice").use_sqlite().build().await?;
let bob = TestClientBuilder::new("bob").use_sqlite().build().await?;

let alice_sync_service = SyncService::builder(alice.clone()).build().await.unwrap();
alice_sync_service.start().await;
Expand Down
Loading

0 comments on commit d28348e

Please sign in to comment.