pub struct TestContext { /* private fields */ }Expand description
Test context for integration tests.
Provides an isolated testing environment with transaction-based isolation, mock HTTP support, and test utilities.
Implementations§
Source§impl TestContext
impl TestContext
Sourcepub fn new_without_db() -> Self
pub fn new_without_db() -> Self
Create a new test context (without database).
Sourcepub async fn with_config(config: TestConfig) -> Result<Self>
pub async fn with_config(config: TestConfig) -> Result<Self>
Create a test context with custom configuration.
Sourcepub fn builder() -> TestContextBuilder
pub fn builder() -> TestContextBuilder
Create a builder for more complex setup.
Sourcepub fn auth(&self) -> &AuthContext
pub fn auth(&self) -> &AuthContext
Get the auth context.
Sourcepub fn mock_http_mut(&mut self) -> &mut MockHttp
pub fn mock_http_mut(&mut self) -> &mut MockHttp
Get mutable mock HTTP.
Sourcepub async fn query<F, I, O>(&self, _func: F, _input: I) -> Result<O>where
F: Fn(QueryContext, I) -> Pin<Box<dyn Future<Output = Result<O>> + Send>>,
I: Serialize,
O: DeserializeOwned,
pub async fn query<F, I, O>(&self, _func: F, _input: I) -> Result<O>where
F: Fn(QueryContext, I) -> Pin<Box<dyn Future<Output = Result<O>> + Send>>,
I: Serialize,
O: DeserializeOwned,
Execute a query function.
Sourcepub async fn mutate<F, I, O>(&self, _func: F, _input: I) -> Result<O>where
F: Fn(MutationContext, I) -> Pin<Box<dyn Future<Output = Result<O>> + Send>>,
I: Serialize,
O: DeserializeOwned,
pub async fn mutate<F, I, O>(&self, _func: F, _input: I) -> Result<O>where
F: Fn(MutationContext, I) -> Pin<Box<dyn Future<Output = Result<O>> + Send>>,
I: Serialize,
O: DeserializeOwned,
Execute a mutation function.
Sourcepub fn dispatch_job(&mut self, job_type: &str, input: Value) -> Uuid
pub fn dispatch_job(&mut self, job_type: &str, input: Value) -> Uuid
Dispatch a job for testing.
Sourcepub fn cancel_job(&mut self, job_id: Uuid)
pub fn cancel_job(&mut self, job_id: Uuid)
Cancel a job (for testing).
Sourcepub fn dispatched_jobs(&self) -> &[DispatchedJob]
pub fn dispatched_jobs(&self) -> &[DispatchedJob]
Get dispatched jobs.
Sourcepub fn job_dispatched(&self, job_type: &str) -> bool
pub fn job_dispatched(&self, job_type: &str) -> bool
Check if a job was dispatched.
Sourcepub fn job_status(&self, job_id: Uuid) -> Option<JobStatus>
pub fn job_status(&self, job_id: Uuid) -> Option<JobStatus>
Get job status.
Sourcepub fn complete_job(&mut self, job_id: Uuid)
pub fn complete_job(&mut self, job_id: Uuid)
Mark a job as completed (for testing).
Sourcepub fn start_workflow(&mut self, workflow_name: &str, input: Value) -> Uuid
pub fn start_workflow(&mut self, workflow_name: &str, input: Value) -> Uuid
Start a workflow for testing.
Sourcepub fn started_workflows(&self) -> &[StartedWorkflow]
pub fn started_workflows(&self) -> &[StartedWorkflow]
Get started workflows.
Sourcepub fn workflow_status(&self, run_id: Uuid) -> Option<WorkflowStatus>
pub fn workflow_status(&self, run_id: Uuid) -> Option<WorkflowStatus>
Get workflow status.
Sourcepub fn complete_workflow_step(&mut self, run_id: Uuid, step_name: &str)
pub fn complete_workflow_step(&mut self, run_id: Uuid, step_name: &str)
Mark a workflow step as completed.
Sourcepub fn complete_workflow(&mut self, run_id: Uuid)
pub fn complete_workflow(&mut self, run_id: Uuid)
Complete a workflow.
Sourcepub fn workflow_step_completed(&self, run_id: Uuid, step_name: &str) -> bool
pub fn workflow_step_completed(&self, run_id: Uuid, step_name: &str) -> bool
Check if a workflow step was completed.
Auto Trait Implementations§
impl Freeze for TestContext
impl !RefUnwindSafe for TestContext
impl Send for TestContext
impl Sync for TestContext
impl Unpin for TestContext
impl !UnwindSafe for TestContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request