Skip to content

Commit

Permalink
test: verify annex availability via a secondary work tree
Browse files Browse the repository at this point in the history
  • Loading branch information
mih committed Oct 25, 2024
1 parent 7d2c3ce commit f634436
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions datalad_core/repo/tests/test_worktree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from datalad_core.config import ConfigItem
from datalad_core.runners import call_git
from datalad_core.runners import call_git_success

from ..worktree import Worktree

Expand Down Expand Up @@ -51,7 +51,7 @@ def test_secondary_worktree(tmp_path, gitrepo):
test_key2 = 'other.brand.new.key'
branch = 'dummy'
wt_path = tmp_path / branch
call_git(
call_git_success(
[
'-C',
str(gitrepo),
Expand Down Expand Up @@ -159,3 +159,35 @@ 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_success(['-C', str(wt1.path), 'annex', 'add', str(test_file)])
call_git_success(['-C', str(wt1.path), 'commit', '-m', 'annexed file'])

branch = 'dummy'
wt2_path = tmp_path / branch
call_git_success(
[
'-C',
str(annexrepo),
'worktree',
'add',
str(wt2_path),
]
)
wt2 = Worktree(wt2_path)
assert wt2.annex is not None
# verifies implicitly that git-annex-info work in both worktrees
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_success(['-C', wt.annex.path, 'annex', 'get', test_file_name])
assert (wt.path / test_file_name).read_text() == test_content

0 comments on commit f634436

Please sign in to comment.