mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
32 lines
1.0 KiB
Rust
32 lines
1.0 KiB
Rust
//! Shared helpers for the migration test modules.
|
|
|
|
use std::path::Path;
|
|
|
|
pub(crate) fn write_agents_json(dir: &Path, records: &serde_json::Value) {
|
|
std::fs::create_dir_all(dir.join("agents")).unwrap();
|
|
std::fs::write(
|
|
dir.join("agents/managed-agents.json"),
|
|
serde_json::to_vec_pretty(records).unwrap(),
|
|
)
|
|
.unwrap();
|
|
}
|
|
|
|
pub(crate) fn read_agents_json(dir: &Path) -> Vec<serde_json::Value> {
|
|
let content = std::fs::read_to_string(dir.join("agents/managed-agents.json")).unwrap();
|
|
serde_json::from_str(&content).unwrap()
|
|
}
|
|
|
|
pub(crate) fn write_personas_json(dir: &Path, records: &serde_json::Value) {
|
|
std::fs::create_dir_all(dir.join("agents")).unwrap();
|
|
std::fs::write(
|
|
dir.join("agents/personas.json"),
|
|
serde_json::to_vec_pretty(records).unwrap(),
|
|
)
|
|
.unwrap();
|
|
}
|
|
|
|
pub(crate) fn read_personas_json(dir: &Path) -> Vec<serde_json::Value> {
|
|
let content = std::fs::read_to_string(dir.join("agents/personas.json")).unwrap();
|
|
serde_json::from_str(&content).unwrap()
|
|
}
|