Extract randomized test infrastructure for use in other tests
This commit is contained in:
parent
ec5ff20b4c
commit
66c3879306
9 changed files with 2887 additions and 2748 deletions
49
crates/collab/src/tests/random_channel_buffer_tests.rs
Normal file
49
crates/collab/src/tests/random_channel_buffer_tests.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
use crate::tests::{run_randomized_test, RandomizedTest, TestClient, TestError, UserTestPlan};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use gpui::{executor::Deterministic, TestAppContext};
|
||||
use rand::rngs::StdRng;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_random_channel_buffers(
|
||||
cx: &mut TestAppContext,
|
||||
deterministic: Arc<Deterministic>,
|
||||
rng: StdRng,
|
||||
) {
|
||||
run_randomized_test::<RandomChannelBufferTest>(cx, deterministic, rng).await;
|
||||
}
|
||||
|
||||
struct RandomChannelBufferTest;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
enum ChannelBufferOperation {
|
||||
Join,
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl RandomizedTest for RandomChannelBufferTest {
|
||||
type Operation = ChannelBufferOperation;
|
||||
|
||||
fn generate_operation(
|
||||
client: &TestClient,
|
||||
rng: &mut StdRng,
|
||||
plan: &mut UserTestPlan,
|
||||
cx: &TestAppContext,
|
||||
) -> ChannelBufferOperation {
|
||||
ChannelBufferOperation::Join
|
||||
}
|
||||
|
||||
async fn apply_operation(
|
||||
client: &TestClient,
|
||||
operation: ChannelBufferOperation,
|
||||
cx: &mut TestAppContext,
|
||||
) -> Result<(), TestError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn on_client_added(client: &Rc<TestClient>) {}
|
||||
|
||||
fn on_clients_quiesced(clients: &[(Rc<TestClient>, TestAppContext)]) {}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue