Add e2e test for repos status

This commit is contained in:
2022-01-04 11:56:55 +01:00
parent a94bd19362
commit f9d9dc587a
2 changed files with 44 additions and 0 deletions

View File

@@ -186,6 +186,37 @@ class TempGitRepositoryWorktree:
del self.remote_2_dir
class RepoTree:
def __init__(self):
pass
def __enter__(self):
self.root = tempfile.TemporaryDirectory()
self.config = tempfile.NamedTemporaryFile()
with open(self.config.name, "w") as f:
f.write(
f"""
[[trees]]
root = "{self.root.name}"
[[trees.repos]]
name = "test"
[[trees.repos]]
name = "test_worktree"
worktree_setup = true
"""
)
cmd = grm(["repos", "sync", "--config", self.config.name])
assert cmd.returncode == 0
return (self.root.name, self.config.name, ["test", "test_worktree"])
def __exit__(self, exc_type, exc_val, exc_tb):
del self.root
del self.config
class EmptyDir:
def __init__(self):
pass

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env python3
import tempfile
from helpers import *
def test_repos_sync_worktree_clone():
with RepoTree() as (root, config, repos):
cmd = grm(["repos", "status", "--config", config])
assert cmd.returncode == 0
for repo in repos:
assert repo in cmd.stdout