pub struct MockJudge { /* private fields */ }Expand description
Canned JudgeClient for tests.
MockJudge replays a pre-configured sequence of judge outcomes, one per
call to JudgeClient::judge. When the sequence is exhausted the judge
returns the configured tail outcome (defaults to a JudgeError::Other
with an explanatory message so tests fail loudly rather than silently).
Call-count tracking is available via MockJudge::call_count so tests can
assert how many times the judge was invoked.
use std::sync::Arc;
use swink_agent_eval::{JudgeClient, JudgeVerdict, MockJudge};
let judge = Arc::new(MockJudge::with_verdicts(vec![JudgeVerdict {
score: 1.0,
pass: true,
reason: Some("looks good".into()),
label: Some("equivalent".into()),
}]));Implementations§
Source§impl MockJudge
impl MockJudge
Sourcepub fn with_verdicts(verdicts: Vec<JudgeVerdict>) -> Self
pub fn with_verdicts(verdicts: Vec<JudgeVerdict>) -> Self
Build a mock judge that returns each verdict in order, then fails loudly
with JudgeError::Other once exhausted.
Sourcepub const fn always_err(err: JudgeError) -> Self
pub const fn always_err(err: JudgeError) -> Self
Build a mock judge that always returns the given JudgeError.
Useful for error-path tests (transport, malformed, timeout).
Sourcepub fn always_pass() -> Self
pub fn always_pass() -> Self
Build a mock judge that returns a single passing verdict every call.
Sourcepub fn always_fail() -> Self
pub fn always_fail() -> Self
Build a mock judge that returns a single failing verdict every call.
Sourcepub fn mixed_sequence(sequence: Vec<Result<JudgeVerdict, JudgeError>>) -> Self
pub fn mixed_sequence(sequence: Vec<Result<JudgeVerdict, JudgeError>>) -> Self
Build a mock judge from a mixed sequence of verdicts and errors. The
sequence is consumed FIFO; once exhausted the tail outcome is
returned on every subsequent call.
Sourcepub fn call_count(&self) -> usize
pub fn call_count(&self) -> usize
Returns how many times judge() has been invoked on this mock.