Skip to content

Commit

Permalink
fix(core): fix rerun overwriting plan details with previous versions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Oct 31, 2022
1 parent 9285fe0 commit 72ad1d5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
4 changes: 4 additions & 0 deletions renku/infrastructure/gateway/plan_gateway.py
Expand Up @@ -66,6 +66,10 @@ def get_all_plans(self) -> List[AbstractPlan]:
def add(self, plan: AbstractPlan) -> None:
"""Add a plan to the database."""
database = project_context.database

if database["plans"].get(plan.id) is not None:
return

database["plans"].add(plan)

if plan.derived_from is not None:
Expand Down
33 changes: 32 additions & 1 deletion tests/cli/test_workflow.py
Expand Up @@ -1385,7 +1385,8 @@ def test_reverted_activity_status(runner, project, with_injection):
write_and_commit_file(project.repository, input, "content")
output = project.path / "output"

assert 0 == runner.invoke(cli, ["run", "cat", input], stdout=output).exit_code
result = runner.invoke(cli, ["run", "cat", input], stdout=output)
assert 0 == result.exit_code, format_result_exception(result)
write_and_commit_file(project.repository, input, "changes")

with with_injection():
Expand All @@ -1409,3 +1410,33 @@ def test_reverted_activity_status(runner, project, with_injection):
assert activity_id not in runner.invoke(cli, ["log"]).output
assert "input" not in runner.invoke(cli, ["workflow", "inputs"]).output
assert "output" not in runner.invoke(cli, ["workflow", "outputs"]).output


def test_rerun_doesnt_update_plan_index(runner, project, with_injection):
"""Test that a rerun does not update the plan index."""
input = project.path / "input"
write_and_commit_file(project.repository, input, "content")
output = project.path / "output"

original_description = "1111111111111111"
result = runner.invoke(
cli, ["run", "--name", "my-workflow", "--description", original_description, "cat", input], stdout=output
)
assert 0 == result.exit_code, format_result_exception(result)

new_description = "22222222222222222"
result = runner.invoke(cli, ["workflow", "edit", "my-workflow", "--description", new_description])
assert 0 == result.exit_code, format_result_exception(result)

result = runner.invoke(cli, ["workflow", "show", "my-workflow"])
assert 0 == result.exit_code, format_result_exception(result)
assert new_description in result.output
assert original_description not in result.output

result = runner.invoke(cli, ["rerun", output])
assert 0 == result.exit_code, format_result_exception(result)

result = runner.invoke(cli, ["workflow", "show", "my-workflow"])
assert 0 == result.exit_code, format_result_exception(result)
assert new_description in result.output
assert original_description not in result.output
4 changes: 2 additions & 2 deletions tests/core/test_plan.py
Expand Up @@ -131,7 +131,7 @@ def test_plan_delete_errors(project_with_injection):

def test_plan_get_initial_id(project_with_injection):
"""Test getting initial id of a plan."""
grand_parent, parent, plan, child, grand_child, unrelated = create_dummy_plans()
grand_parent, parent, plan, child, grand_child, _ = create_dummy_plans()

initial_id = get_initial_id(plan)

Expand All @@ -143,7 +143,7 @@ def test_plan_get_initial_id(project_with_injection):

def test_get_activities(project_with_injection):
"""Test getting activities of a plan."""
grand_parent, parent, plan, child, grand_child, unrelated = create_dummy_plans()
grand_parent, _, plan, child, grand_child, unrelated = create_dummy_plans()
activities = [
create_dummy_activity(plan),
create_dummy_activity(grand_parent),
Expand Down

0 comments on commit 72ad1d5

Please sign in to comment.