From 3ea96b427fbd862e248a6122f4d0d988d260b667 Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Fri, 25 Oct 2024 10:39:59 +0200 Subject: [PATCH] test: verify annex availability via a secondary work tree Refs: https://github.com/datalad/datalad-remake/issues/21 --- datalad_core/repo/tests/test_worktree.py | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/datalad_core/repo/tests/test_worktree.py b/datalad_core/repo/tests/test_worktree.py index 9d31714..4c4fa09 100644 --- a/datalad_core/repo/tests/test_worktree.py +++ b/datalad_core/repo/tests/test_worktree.py @@ -159,3 +159,34 @@ def test_worktree_init_at(tmp_path): # we got a new instance for the repo assert sep_wt.repo is not sep_repo_old assert sep_wt.repo.path == sep_repo_path_new + + +def test_secondary_worktree_w_annex(tmp_path, annexrepo): + wt1 = Worktree(annexrepo) + test_content = 'mycontent' + test_file_name = 'myfile.dat' + test_file = wt1.path / test_file_name + test_file.write_text(test_content) + call_git(['-C', str(wt1.path), 'annex', 'add', str(test_file)]) + call_git(['-C', str(wt1.path), 'commit', '-m', 'annexed file']) + + branch = 'dummy' + wt2_path = tmp_path / branch + call_git( + [ + '-C', + str(annexrepo), + 'worktree', + 'add', + str(wt2_path), + ] + ) + wt2 = Worktree(wt2_path) + assert wt2.annex is not None + assert wt1.annex.uuid == wt2.annex.uuid + + for wt in (wt1, wt2): + # annex-getting the content is needed for robustness, not all + # platforms have immediately usable symlinks to the annex + call_git(['-C', wt.annex.path, 'annex', 'get', test_file_name]) + assert (wt.path / test_file_name).read_text() == test_content