1
0
Fork 0
mirror of synced 2024-12-04 14:45:36 -05:00

test(clone): run inside YADM_WORK sub-directory

Whenever using `clone` command inside YADM_WORK sub-directory, we need
to checkout the correct repo contents.

Steps to reproduce:

```bash
mkdir $HOME/subdir
cd $HOME/subdir

yadm clone --bootstrap "<repo-url>"
yadm status
```
This commit is contained in:
AVM.Martin 2024-07-21 04:58:42 +07:00
parent 76ce3defea
commit 12c51e130b
No known key found for this signature in database
GPG key ID: 25F846A221B3F159

View file

@ -326,3 +326,32 @@ def test_no_repo(
def verify_head(paths, branch):
"""Assert the local repo has the correct head branch"""
assert paths.repo.join("HEAD").read() == f"ref: refs/heads/{branch}\n"
@pytest.mark.usefixtures("remote")
def test_clone_subdirectory(runner, paths, yadm_cmd, repo_config):
"""Test clone from sub-directory of YADM_WORK"""
# clear out the work path
paths.work.remove()
paths.work.mkdir()
# create sub-directory
subdir = paths.work.mkdir("subdir")
# determine remote url
remote_url = f"file://{paths.remote}"
# run the clone command
args = ["clone", "-w", paths.work]
args += [remote_url]
run = runner(command=yadm_cmd(*args), cwd=subdir)
# clone should succeed, and repo should be configured properly
assert successful_clone(run, paths, repo_config)
# test that the conflicts are preserved in the work tree
run = runner(command=yadm_cmd("status", "-uno", "--porcelain"), cwd=subdir)
assert run.success
assert run.out == ""
assert run.err == ""