Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #82 from rodgomes/master
Browse files Browse the repository at this point in the history
OPT: add output field to pipelinerun
  • Loading branch information
rodgomes authored Mar 19, 2020
2 parents 996001f + b3f7a3d commit 39a09f7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions katka/migrations/0033_scmpipelinerun_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2.9 on 2020-03-19 12:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("katka", "0032_added_step_aborted"),
]

operations = [
migrations.AddField(model_name="scmpipelinerun", name="output", field=models.TextField(blank=True),),
]
1 change: 1 addition & 0 deletions katka/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class Meta:
steps_completed = models.PositiveSmallIntegerField(default=0)
pipeline_yaml = models.TextField(default="---")
application = models.ForeignKey(Application, on_delete=models.PROTECT)
output = models.TextField(blank=True)


class SCMStepRun(AuditedModel):
Expand Down
1 change: 1 addition & 0 deletions katka/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Meta:
"pipeline_yaml",
"application",
"scmrelease_set",
"output",
)
read_only_fields = ("scmrelease_set",)

Expand Down
15 changes: 15 additions & 0 deletions tests/integration/test_scmpipelinerun_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ def test_create_first_commit(self, client, logged_in_user, application, scm_pipe
assert new_plr.first_parent_hash is None
assert new_plr.status == PIPELINE_STATUS_INITIALIZING

def test_create_with_output(self, client, logged_in_user, application, scm_pipeline_run):
initial_count = models.SCMPipelineRun.objects.count()
url = f"/scm-pipeline-runs/"
data = {
"output": "a output",
"commit_hash": "874AE57A143AEC5156FD1444A017A32137A3E34A",
"application": application.public_identifier,
}
response = client.post(url, data=data, content_type="application/json")
assert response.status_code == 201
assert models.SCMPipelineRun.objects.count() == initial_count + 1
new_plr = models.SCMPipelineRun.objects.filter(output="a output").first()
assert new_plr.first_parent_hash is None
assert new_plr.status == PIPELINE_STATUS_INITIALIZING

def test_create_next_commit(self, client, logged_in_user, application, scm_pipeline_run):
initial_count = models.SCMPipelineRun.objects.count()
url = f"/scm-pipeline-runs/"
Expand Down

0 comments on commit 39a09f7

Please sign in to comment.