Files
huskies/server/src/chat/test_helpers.rs
T

19 lines
830 B
Rust
Raw Normal View History

//! Shared test utilities for chat handler tests.
//!
//! Import with `use crate::chat::test_helpers::write_story_file;`
use std::path::Path;
/// Write a work-item file into the standard pipeline directory structure.
///
/// Creates `.huskies/work/{stage}/{filename}` under `root`, creating any
/// missing parent directories. Also writes to the global content store so
/// that code paths that prefer the content store over the filesystem (e.g.
/// `unblock_by_number`) see this test's content rather than a stale entry
/// left by a parallel test with the same numeric prefix.
pub(crate) fn write_story_file(root: &Path, stage: &str, filename: &str, content: &str) {
let dir = root.join(".huskies/work").join(stage);
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join(filename), content).unwrap();
}