huskies: merge 1111 bug Test isolation: init_for_test() and ensure_content_store() are once-per-thread, not once-per-test, polluting CRDT state across tests
This commit is contained in:
@@ -86,6 +86,7 @@ mod tests {
|
||||
use crate::http::test_helpers::test_ctx;
|
||||
|
||||
fn setup_git_repo_in(dir: &std::path::Path) {
|
||||
crate::db::ensure_content_store();
|
||||
std::process::Command::new("git")
|
||||
.args(["init"])
|
||||
.current_dir(dir)
|
||||
|
||||
@@ -115,6 +115,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_refactor_accepts_single_criterion() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_create_refactor(
|
||||
@@ -146,6 +147,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_refactor_accepts_mixed_junk_and_real_acceptance_criteria() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_create_refactor(
|
||||
|
||||
@@ -118,6 +118,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_spike_creates_file() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
|
||||
@@ -147,6 +148,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_spike_creates_file_without_description() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
|
||||
@@ -202,6 +204,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_spike_accepts_single_criterion() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_create_spike(
|
||||
@@ -233,6 +236,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_spike_accepts_mixed_junk_and_real_acceptance_criteria() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_create_spike(
|
||||
|
||||
@@ -256,6 +256,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_story_accepts_single_criterion() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_create_story(
|
||||
@@ -283,6 +284,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_story_accepts_mixed_junk_and_real_acceptance_criteria() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_create_story(
|
||||
@@ -299,6 +301,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_story_description_is_written_to_file() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
|
||||
@@ -368,6 +371,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_story_html_sanitised_in_name() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
// HTML in name is sanitised (not rejected)
|
||||
|
||||
@@ -124,6 +124,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn tool_create_story_and_list_upcoming() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
// No git repo needed: spike 61 — create_story just writes the file;
|
||||
// the filesystem watcher handles the commit asynchronously.
|
||||
|
||||
@@ -6,6 +6,7 @@ use super::spike::create_spike_file;
|
||||
use std::fs;
|
||||
|
||||
fn setup_git_repo(root: &std::path::Path) {
|
||||
crate::db::ensure_content_store();
|
||||
std::process::Command::new("git")
|
||||
.args(["init"])
|
||||
.current_dir(root)
|
||||
@@ -166,6 +167,7 @@ fn extract_bug_name_from_content_parses_heading() {
|
||||
|
||||
#[test]
|
||||
fn create_bug_file_writes_correct_content() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
setup_git_repo(tmp.path());
|
||||
|
||||
@@ -257,6 +259,7 @@ fn create_bug_file_rejects_empty_acceptance_criteria() {
|
||||
|
||||
#[test]
|
||||
fn create_spike_file_writes_correct_content() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
let spike_id = create_spike_file(
|
||||
@@ -294,6 +297,7 @@ fn create_spike_file_writes_correct_content() {
|
||||
|
||||
#[test]
|
||||
fn create_spike_file_uses_description_when_provided() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let description = "What is the best approach for watching filesystem events?";
|
||||
|
||||
@@ -319,6 +323,7 @@ fn create_spike_file_uses_description_when_provided() {
|
||||
|
||||
#[test]
|
||||
fn create_spike_file_uses_placeholder_when_no_description() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let spike_id = create_spike_file(
|
||||
tmp.path(),
|
||||
@@ -350,6 +355,7 @@ fn create_spike_file_rejects_empty_name() {
|
||||
|
||||
#[test]
|
||||
fn create_spike_file_with_special_chars_in_name_produces_valid_yaml() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let name = "Spike: compare \"fast\" vs slow encoders";
|
||||
let result = create_spike_file(
|
||||
@@ -423,6 +429,7 @@ fn create_bug_file_with_depends_on_persists_to_crdt() {
|
||||
|
||||
#[test]
|
||||
fn create_bug_file_without_depends_on_omits_field() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
setup_git_repo(tmp.path());
|
||||
|
||||
@@ -474,6 +481,7 @@ fn create_refactor_file_with_depends_on_persists_to_crdt() {
|
||||
|
||||
#[test]
|
||||
fn create_refactor_file_without_depends_on_omits_field() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
setup_git_repo(tmp.path());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user