Files
clawmates/crates/cm-files/tests/s3_store.rs
T
Omar SobhandClaude Fable 5 add4f79fed Rebrand: TeamClaw -> Clawmates (clawmates.work)
Full-depth rename per the approved plan; the 'claw' product vocabulary
(claws, /claws routes, clawId, Claw Chat) stays — it is now the brand.

- Display brand: Clawmates (manifest, titles, hero, login/rail logo
  'clawmates'); default host app.clawmates.work; registry
  ghcr.io/clawmates
- Crates tc-* -> cm-* (16 crates + all imports); binaries
  clawmates-server/broker/bundler; images clawmates/*; env prefix
  CLAWMATES_* (+ CM_TEST_DATABASE_URL / CM_LIVE_LLM); config
  clawmates.toml; helm chart deploy/helm/clawmates with clawmates-*
  resources; db names clawmates*; sockets /run/clawmates; cookie
  cm_session; kind cluster clawmates-test; seccomp node profile
  clawmates-agent-profile.json
- All 9 Playwright brand assertions updated in lockstep; historical
  spec document left untouched as the only remaining 'TeamClaw'
- Local env migrated: dev pg clawmates-dev-pg/clawmates_dev, shared
  test server clawmates-test-pg, kind cluster recreated with image +
  profile, compose images rebuilt under clawmates/*

Verified end to end: 161 Rust + 68 frontend tests, 29 Playwright
journeys, 4 live kind tests, helm/install/LOC/placeholder gates, and
the clean-room install rehearsal serving the clawmates login page from
a signed bundle of the rebuilt images.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-10 12:31:25 -05:00

92 lines
3.0 KiB
Rust

//! The cloud-target blob store against a REAL S3-compatible server
//! (MinIO in a container) — same contract the local store satisfies.
use testcontainers_modules::testcontainers::core::{ExecCommand, IntoContainerPort, WaitFor};
use testcontainers_modules::testcontainers::runners::AsyncRunner;
use testcontainers_modules::testcontainers::{GenericImage, ImageExt};
use cm_files::{BlobError, BlobStore, S3BlobStore};
async fn minio_store() -> (
S3BlobStore,
testcontainers_modules::testcontainers::ContainerAsync<GenericImage>,
) {
let container = GenericImage::new("minio/minio", "latest")
.with_exposed_port(9000.tcp())
.with_wait_for(WaitFor::message_on_either_std("API:"))
.with_env_var("MINIO_ROOT_USER", "tc-access")
.with_env_var("MINIO_ROOT_PASSWORD", "tc-secret-key")
.with_cmd(["server", "/data"])
.start()
.await
.expect("minio starts");
// Create the bucket with the bundled mc client.
container
.exec(ExecCommand::new([
"sh",
"-c",
"mc alias set local http://127.0.0.1:9000 tc-access tc-secret-key && mc mb local/clawmates",
]))
.await
.expect("bucket created");
let port = container.get_host_port_ipv4(9000).await.unwrap();
// The bucket is created asynchronously after boot; retry connect+probe.
let store = S3BlobStore::connect(
&format!("http://127.0.0.1:{port}"),
"clawmates",
"tc-access",
"tc-secret-key",
)
.expect("client builds");
for _ in 0..50 {
if store.put("probe", b"x").await.is_ok() {
store.delete("probe").await.ok();
return (store, container);
}
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
}
panic!("minio bucket never became writable");
}
#[tokio::test]
async fn s3_round_trip_overwrite_and_missing_keys() {
let (store, _container) = minio_store().await;
store
.put("ws1/documents/agent1/report.md", b"# Q2 Report")
.await
.unwrap();
assert_eq!(
store.get("ws1/documents/agent1/report.md").await.unwrap(),
b"# Q2 Report"
);
// Overwrite replaces.
store
.put("ws1/documents/agent1/report.md", b"# Q3 Report")
.await
.unwrap();
assert_eq!(
store.get("ws1/documents/agent1/report.md").await.unwrap(),
b"# Q3 Report"
);
// Delete then NotFound on both get and delete.
store
.delete("ws1/documents/agent1/report.md")
.await
.unwrap();
assert!(matches!(
store.get("ws1/documents/agent1/report.md").await,
Err(BlobError::NotFound)
));
assert!(matches!(
store.delete("ws1/documents/agent1/report.md").await,
Err(BlobError::NotFound)
));
// Nested keys work without directory semantics.
store.put("a/b/c/deep.txt", b"deep").await.unwrap();
assert_eq!(store.get("a/b/c/deep.txt").await.unwrap(), b"deep");
}