Base: codex-main originale (prima del fork aKode)
This commit is contained in:
7
codex-rs/protocol/tests/support/BUILD.bazel
Normal file
7
codex-rs/protocol/tests/support/BUILD.bazel
Normal file
@@ -0,0 +1,7 @@
|
||||
load("//:defs.bzl", "codex_rust_crate")
|
||||
|
||||
codex_rust_crate(
|
||||
name = "support",
|
||||
crate_name = "codex_protocol_test_support",
|
||||
crate_srcs = glob(["*.rs"]),
|
||||
)
|
||||
17
codex-rs/protocol/tests/support/Cargo.toml
Normal file
17
codex-rs/protocol/tests/support/Cargo.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "codex-protocol-test-support"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
test = false
|
||||
doctest = false
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
codex-protocol = { workspace = true }
|
||||
uuid = { workspace = true, features = ["v7"] }
|
||||
28
codex-rs/protocol/tests/support/lib.rs
Normal file
28
codex-rs/protocol/tests/support/lib.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
//! Protocol fixtures and text assertions shared by test targets.
|
||||
|
||||
use codex_protocol::ItemIdGenerator;
|
||||
use codex_protocol::ResponseItemId;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn uuid_v7_item_id_generator_for_test() -> ItemIdGenerator {
|
||||
Arc::new(|prefix| ResponseItemId::with_suffix(prefix, uuid::Uuid::now_v7()))
|
||||
}
|
||||
|
||||
/// Assertion helpers for tests that require text rather than media content.
|
||||
/// Implementations should fail at the calling assertion for non-text content.
|
||||
pub trait ContentItemTestExt {
|
||||
/// Extracts text, panicking at the call site when the content is not text.
|
||||
#[track_caller]
|
||||
fn expect_text(self) -> String;
|
||||
}
|
||||
|
||||
impl ContentItemTestExt for ContentItem {
|
||||
#[track_caller]
|
||||
fn expect_text(self) -> String {
|
||||
match self.into_text() {
|
||||
Some(text) => text,
|
||||
None => panic!("expected text content"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user