Skip to content

Commit

Permalink
chore: increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzzzzzzz committed May 24, 2024
1 parent 3cda8bd commit 4a27bec
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
56 changes: 56 additions & 0 deletions pkg/reconciler/pipelinerun/resources/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4840,6 +4840,62 @@ func TestPropagateArtifacts(t *testing.T) {
},
},
},
{
name: "propagate artifacts outputs",
resolvedTask: &resources.ResolvedPipelineTask{
ResolvedTask: &taskresources.ResolvedTask{
TaskSpec: &v1.TaskSpec{
Steps: []v1.Step{
{
Name: "get-artifacts-outputs-from-pt1",
Command: []string{"$(tasks.pt1.outputs)"},
Args: []string{"$(tasks.pt1.outputs.image)"},
},
},
},
},
},
runStates: resources.PipelineRunState{
{
PipelineTask: &v1.PipelineTask{
Name: "pt1",
},
TaskRuns: []*v1.TaskRun{
{
Status: v1.TaskRunStatus{
Status: duckv1.Status{
Conditions: duckv1.Conditions{
{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
},
},
},
TaskRunStatusFields: v1.TaskRunStatusFields{
Artifacts: v1.Artifacts{
Inputs: []v1.Artifact{{Name: "source", Values: []v1.ArtifactValue{{Digest: map[v1.Algorithm]string{"sha256": "b35cacccfdb1e24dc497d15d553891345fd155713ffe647c281c583269eaaae0"}, Uri: "pkg:example.github.com/inputs"}}}},
Outputs: []v1.Artifact{{Name: "image", Values: []v1.ArtifactValue{{Digest: map[v1.Algorithm]string{"sha1": "95588b8f34c31eb7d62c92aaa4e6506639b06ef2"}, Uri: "pkg:github/package-url/purl-spec@244fd47e07d1004f0aed9c"}}}},
},
},
},
},
},
},
},
expectedResolvedTask: &resources.ResolvedPipelineTask{
ResolvedTask: &taskresources.ResolvedTask{
TaskSpec: &v1.TaskSpec{
Steps: []v1.Step{
{
Name: "get-artifacts-outputs-from-pt1",
Command: []string{`[{"digest":{"sha1":"95588b8f34c31eb7d62c92aaa4e6506639b06ef2"},"uri":"pkg:github/package-url/purl-spec@244fd47e07d1004f0aed9c"}]`},
Args: []string{`[{"digest":{"sha1":"95588b8f34c31eb7d62c92aaa4e6506639b06ef2"},"uri":"pkg:github/package-url/purl-spec@244fd47e07d1004f0aed9c"}]`},
},
},
},
},
},
},
} {
t.Run(tt.name, func(t *testing.T) {
err := resources.PropagateArtifacts(tt.resolvedTask, tt.runStates)
Expand Down
6 changes: 5 additions & 1 deletion pkg/result/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ func TestRunResult_UnmarshalJSON(t *testing.T) {
data: "{\"key\":\"resultName\",\"value\":\"\", \"type\": \"InternalTektonResult\"}",
pr: RunResult{Key: "resultName", Value: "", ResultType: InternalTektonResultType},
}, {
name: "type defined as string - ArtifactsResult",
name: "type defined as string - StepArtifactsResultType",
data: "{\"key\":\"resultName\",\"value\":\"\", \"type\": \"StepArtifactsResult\"}",
pr: RunResult{Key: "resultName", Value: "", ResultType: StepArtifactsResultType},
}, {
name: "type defined as string - TaskRunArtifactResult",
data: "{\"key\":\"resultName\",\"value\":\"\", \"type\": \"TaskRunArtifactsResult\"}",
pr: RunResult{Key: "resultName", Value: "", ResultType: TaskRunArtifactsResultType},
}, {
name: "type defined as int",
data: "{\"key\":\"resultName\",\"value\":\"\", \"type\": 1}",
Expand Down

0 comments on commit 4a27bec

Please sign in to comment.