mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-20 02:16:39 +00:00
feat: installed package keeps its data in ~/.docsgpt/server
Outside a checkout the data home was the working directory, so running `docsgpt api` from another folder silently used different settings and data. It is now ~/.docsgpt/server (/opt/docsgpt for root on Linux); DOCSGPT_HOME and a checkout still take precedence. The API and worker commands create the home and point out a .env left in the working directory.
This commit is contained in:
1 parent
95fd4bdefe
commit
ac06527a8d
4 files changed
+106
-11
No files matched your search
@@ -20,11 +20,31 @@ class TestHomeDir:
|
||||
monkeypatch.setenv(paths.HOME_ENV, str(tmp_path))
|
||||
assert paths.home_dir() == tmp_path.resolve()
|
||||
|
||||
def test_an_installed_package_falls_back_to_cwd(self, monkeypatch, tmp_path):
|
||||
def test_an_installed_package_uses_the_default_home_not_cwd(self, monkeypatch, tmp_path):
|
||||
"""`docsgpt api` from any directory finds the same .env and data."""
|
||||
monkeypatch.delenv(paths.HOME_ENV, raising=False)
|
||||
monkeypatch.setattr(paths, "checkout_root", lambda: None)
|
||||
monkeypatch.setattr(paths, "default_home", lambda: tmp_path / "home")
|
||||
monkeypatch.chdir(tmp_path)
|
||||
assert paths.home_dir() == Path.cwd()
|
||||
assert paths.home_dir() == tmp_path / "home"
|
||||
|
||||
|
||||
class TestDefaultHome:
|
||||
def test_a_user_gets_a_folder_in_their_home(self, monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(paths.sys, "platform", "darwin")
|
||||
monkeypatch.setattr(paths.Path, "home", classmethod(lambda cls: tmp_path))
|
||||
assert paths.default_home() == tmp_path / ".docsgpt" / "server"
|
||||
|
||||
def test_root_on_linux_gets_opt(self, monkeypatch):
|
||||
monkeypatch.setattr(paths.sys, "platform", "linux")
|
||||
monkeypatch.setattr(paths.os, "geteuid", lambda: 0, raising=False)
|
||||
assert paths.default_home() == Path("/opt/docsgpt")
|
||||
|
||||
def test_a_normal_user_on_linux_stays_in_their_home(self, monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(paths.sys, "platform", "linux")
|
||||
monkeypatch.setattr(paths.os, "geteuid", lambda: 1000, raising=False)
|
||||
monkeypatch.setattr(paths.Path, "home", classmethod(lambda cls: tmp_path))
|
||||
assert paths.default_home() == tmp_path / ".docsgpt" / "server"
|
||||
|
||||
|
||||
class TestEnvFile:
|
||||
|
||||
Reference in new issue
Block a user