Set up a temp project dir with sample files. Cleans up with ``ccc reset --all -f`` and daemon stop.
()
| 105 | |
| 106 | @pytest.fixture() |
| 107 | def e2e_project() -> Iterator[Path]: |
| 108 | """Set up a temp project dir with sample files. |
| 109 | |
| 110 | Cleans up with ``ccc reset --all -f`` and daemon stop. |
| 111 | """ |
| 112 | base_dir = Path(tempfile.mkdtemp(prefix="ccc_e2e_")) |
| 113 | project_dir = base_dir / "project" |
| 114 | project_dir.mkdir() |
| 115 | (project_dir / "main.py").write_text(SAMPLE_MAIN_PY) |
| 116 | (project_dir / "utils.py").write_text(SAMPLE_UTILS_PY) |
| 117 | lib_dir = project_dir / "lib" |
| 118 | lib_dir.mkdir() |
| 119 | (lib_dir / "database.py").write_text(SAMPLE_DATABASE_PY) |
| 120 | (project_dir / ".git").mkdir() |
| 121 | |
| 122 | old_env = os.environ.get("COCOINDEX_CODE_DIR") |
| 123 | os.environ["COCOINDEX_CODE_DIR"] = str(base_dir) |
| 124 | old_cwd = os.getcwd() |
| 125 | os.chdir(project_dir) |
| 126 | |
| 127 | # Pre-write global settings with the lightweight test model so `ccc init` |
| 128 | # in these tests skips the new interactive flow and existing assertions |
| 129 | # continue to exercise the same indexing behavior as before. |
| 130 | save_user_settings(make_test_user_settings()) |
| 131 | |
| 132 | try: |
| 133 | yield project_dir |
| 134 | finally: |
| 135 | os.chdir(project_dir) |
| 136 | runner.invoke(app, ["reset", "--all", "-f"]) |
| 137 | stop_daemon() |
| 138 | os.chdir(old_cwd) |
| 139 | if old_env is None: |
| 140 | os.environ.pop("COCOINDEX_CODE_DIR", None) |
| 141 | else: |
| 142 | os.environ["COCOINDEX_CODE_DIR"] = old_env |
| 143 | |
| 144 | |
| 145 | # --------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected