aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-08 01:11:38 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-08 01:11:38 +0200
commited0c680790950354f15fb5835e1d7b213efa1bf8 (patch)
tree59af376652005a0b02c95945c1df6044882a94e5 /packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py
parent4c8e4fb8b8fcd3f78bf4e3e736a058c351aac973 (diff)
downloadmeshbay-ed0c680790950354f15fb5835e1d7b213efa1bf8.tar.gz
fix(node): name a root after its drive when its basename is taken
Two drives with a folder of the same name made the second add fail, and no screen could supply another name. add_root now names it "Name (H)" or "Name (parent)"; a name the operator typed is still refused on a clash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py')
-rw-r--r--packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py b/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py
index b2b3650..1a0d9f1 100644
--- a/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py
+++ b/packages/meshbay-node/tests/test_root_ops_reach_the_live_set.py
@@ -235,6 +235,37 @@ async def test_adding_the_same_directory_twice_is_still_refused(tmp_path):
await roster.close()
+@pytest.mark.parametrize("sent_name", ["", "Archives"])
+async def test_the_same_folder_name_on_two_drives_gets_a_name_of_its_own(tmp_path, sent_name):
+ """The picker sends the basename; the second folder must not be refused for it."""
+ state, roster = await _state(tmp_path)
+ for drive in ("g", "h"):
+ (tmp_path / drive / "Archives").mkdir(parents=True)
+ try:
+ first = await ops.add_root(state, GROUP, str(tmp_path / "g" / "Archives"),
+ name=sent_name)
+ second = await ops.add_root(state, GROUP, str(tmp_path / "h" / "Archives"),
+ name=sent_name)
+ assert first["name"] == "Archives"
+ assert second["name"] == "Archives (h)"
+ assert {"Archives", "Archives (h)"} <= set(_rebuilt(state).names), (
+ "the name given to the second folder did not reach node.toml")
+ assert 'name = "Archives (h)"' in Path(state["config_path"]).read_text(
+ encoding="utf-8")
+ finally:
+ await roster.close()
+
+
+async def test_a_name_somebody_chose_is_still_refused_on_a_clash(tmp_path):
+ state, roster = await _state(tmp_path)
+ (tmp_path / "other").mkdir()
+ try:
+ with pytest.raises(ops.OpError, match="both be called"):
+ await ops.add_root(state, GROUP, str(tmp_path / "other"), name="one")
+ finally:
+ await roster.close()
+
+
async def test_a_second_different_root_still_lands(tmp_path):
state, roster = await _state(tmp_path)
(tmp_path / "uploads").mkdir()