Add delete_recipe helper function and test

Use delete_recipe in the test so that both it and delete_file are
covered.
This commit is contained in:
Brian C. Lane 2017-11-13 12:20:38 -08:00
parent 6e453e70dc
commit c937e69d3b
2 changed files with 16 additions and 1 deletions

View File

@ -343,6 +343,21 @@ def list_commit_files(repo, commit):
tree = commit_obj.get_tree() tree = commit_obj.get_tree()
return sorted([tree.get(i).get_name() for i in range(0,tree.size())]) return sorted([tree.get(i).get_name() for i in range(0,tree.size())])
def delete_recipe(repo, branch, recipe_name):
"""Delete a recipe from a branch.
:param repo: Open repository
:type repo: Git.Repository
:param branch: Branch name
:type branch: str
:param recipe_name: Recipe name to delete
:type recipe_name: str
:returns: OId of the new commit
:rtype: Git.OId
:raises: Can raise errors from Ggit
"""
return delete_file(repo, branch, recipe_filename(recipe_name))
def delete_file(repo, branch, filename): def delete_file(repo, branch, filename):
"""Delete a file from a branch. """Delete a file from a branch.

View File

@ -174,7 +174,7 @@ class GitRecipesTest(unittest.TestCase):
def test_08_delete_recipe(self): def test_08_delete_recipe(self):
"""Test deleting a file from a branch""" """Test deleting a file from a branch"""
oid = recipes.delete_file(self.repo, "master", "http-server.toml") oid = recipes.delete_recipe(self.repo, "master", "http-server")
self.assertNotEqual(oid, None) self.assertNotEqual(oid, None)
master_files = recipes.list_branch_files(self.repo, "master") master_files = recipes.list_branch_files(self.repo, "master")