Fix a problem with diff/NEWEST/WORKSPACE
If there is no WORKSPACE yet it was not falling back to using NEWEST. Also add a test for this.
This commit is contained in:
parent
06648d415a
commit
74326ba7a3
@ -1156,6 +1156,10 @@ def v0_api(api):
|
||||
if to_commit == "WORKSPACE":
|
||||
with api.config["GITLOCK"].lock:
|
||||
new_recipe = workspace_read(api.config["GITLOCK"].repo, branch, recipe_name)
|
||||
# If there is no workspace, use the newest commit instead
|
||||
if not new_recipe:
|
||||
with api.config["GITLOCK"].lock:
|
||||
new_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name)
|
||||
elif to_commit == "NEWEST":
|
||||
with api.config["GITLOCK"].lock:
|
||||
new_recipe = read_recipe_commit(api.config["GITLOCK"].repo, branch, recipe_name)
|
||||
|
@ -155,6 +155,13 @@ class ServerTestCase(unittest.TestCase):
|
||||
self.assertEqual(data["recipes"][0]["name"], "http-server")
|
||||
self.assertEqual(len(data["recipes"][0]["changes"]), 1)
|
||||
|
||||
def test_04a_recipes_diff_empty_ws(self):
|
||||
"""Test the /api/v0/diff/NEWEST/WORKSPACE with empty workspace"""
|
||||
resp = self.server.get("/api/v0/recipes/diff/glusterfs/NEWEST/WORKSPACE")
|
||||
data = json.loads(resp.data)
|
||||
self.assertNotEqual(data, None)
|
||||
self.assertEqual(data, {"diff": []})
|
||||
|
||||
def test_05_recipes_new_json(self):
|
||||
"""Test the /api/v0/recipes/new route with json recipe"""
|
||||
test_recipe = {"description": "An example GlusterFS server with samba",
|
||||
|
Loading…
Reference in New Issue
Block a user