storkit: merge 444_refactor_extract_shared_test_helpers_test_ctx_write_story_file_make_api
This commit is contained in:
@@ -142,11 +142,7 @@ mod tests {
|
||||
try_handle_command(&dispatch, &format!("@timmy move {args}"))
|
||||
}
|
||||
|
||||
fn write_story_file(root: &std::path::Path, stage: &str, filename: &str, content: &str) {
|
||||
let dir = root.join(".storkit/work").join(stage);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join(filename), content).unwrap();
|
||||
}
|
||||
use crate::chat::test_helpers::write_story_file;
|
||||
|
||||
#[test]
|
||||
fn move_command_is_registered() {
|
||||
|
||||
@@ -91,11 +91,7 @@ mod tests {
|
||||
try_handle_command(&dispatch, &format!("@timmy show {args}"))
|
||||
}
|
||||
|
||||
fn write_story_file(root: &std::path::Path, stage: &str, filename: &str, content: &str) {
|
||||
let dir = root.join(".storkit/work").join(stage);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join(filename), content).unwrap();
|
||||
}
|
||||
use crate::chat::test_helpers::write_story_file;
|
||||
|
||||
#[test]
|
||||
fn show_command_is_registered() {
|
||||
|
||||
@@ -296,11 +296,7 @@ mod tests {
|
||||
try_handle_command(&dispatch, &format!("@timmy status {args}"))
|
||||
}
|
||||
|
||||
fn write_story_file(root: &Path, stage: &str, filename: &str, content: &str) {
|
||||
let dir = root.join(".storkit/work").join(stage);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join(filename), content).unwrap();
|
||||
}
|
||||
use crate::chat::test_helpers::write_story_file;
|
||||
|
||||
// -- registration -------------------------------------------------------
|
||||
|
||||
|
||||
@@ -164,11 +164,7 @@ mod tests {
|
||||
try_handle_command(&dispatch, &format!("@timmy unblock {args}"))
|
||||
}
|
||||
|
||||
fn write_story_file(root: &std::path::Path, stage: &str, filename: &str, content: &str) {
|
||||
let dir = root.join(".storkit/work").join(stage);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join(filename), content).unwrap();
|
||||
}
|
||||
use crate::chat::test_helpers::write_story_file;
|
||||
|
||||
#[test]
|
||||
fn unblock_command_is_registered() {
|
||||
|
||||
@@ -8,6 +8,8 @@ pub mod commands;
|
||||
pub mod timer;
|
||||
pub mod transport;
|
||||
pub mod util;
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test_helpers;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//! 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 `.storkit/work/{stage}/{filename}` under `root`, creating any
|
||||
/// missing parent directories.
|
||||
pub(crate) fn write_story_file(root: &Path, stage: &str, filename: &str, content: &str) {
|
||||
let dir = root.join(".storkit/work").join(stage);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join(filename), content).unwrap();
|
||||
}
|
||||
@@ -350,11 +350,7 @@ mod tests {
|
||||
|
||||
// -- handle_assign (no running coder) ------------------------------------
|
||||
|
||||
fn write_story_file(root: &Path, stage: &str, filename: &str, content: &str) {
|
||||
let dir = root.join(".storkit/work").join(stage);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join(filename), content).unwrap();
|
||||
}
|
||||
use crate::chat::test_helpers::write_story_file;
|
||||
|
||||
#[tokio::test]
|
||||
async fn handle_assign_returns_not_found_for_unknown_number() {
|
||||
|
||||
Reference in New Issue
Block a user