Skip to content

Commit

Permalink
Add TaskResults to testbuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
  • Loading branch information
waveywaves authored and tekton-robot committed Mar 19, 2020
1 parent 5d39a72 commit d8ddbde
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/builder/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type TaskRunStatusOp func(*v1alpha1.TaskRunStatus)
// TaskRefOp is an operation which modify a TaskRef struct.
type TaskRefOp func(*v1alpha1.TaskRef)

// TaskResultOp is an operation which modifies there
type TaskResultOp func(result *v1beta1.TaskResult)

// TaskRunInputsOp is an operation which modify a TaskRunInputs struct.
type TaskRunInputsOp func(*v1alpha1.TaskRunInputs)

Expand Down Expand Up @@ -247,6 +250,17 @@ func TaskResources(ops ...TaskResourcesOp) TaskSpecOp {
}
}

// TaskResults sets the Results to the TaskSpec
func TaskResults(name, desc string) TaskSpecOp {
return func(spec *v1alpha1.TaskSpec) {
r := &v1beta1.TaskResult{
Name: name,
Description: desc,
}
spec.Results = append(spec.Results, *r)
}
}

// TaskResourcesInput adds a TaskResource as Inputs to the TaskResources
func TaskResourcesInput(name string, resourceType v1alpha1.PipelineResourceType, ops ...TaskResourceOp) TaskResourcesOp {
return func(r *v1beta1.TaskResources) {
Expand Down Expand Up @@ -279,6 +293,19 @@ func TaskResourcesOutput(name string, resourceType v1alpha1.PipelineResourceType
}
}

// TaskResultsOutput adds a TaskResult as Outputs to the TaskResources
func TaskResultsOutput(name, desc string, ops ...TaskResultOp) TaskResultOp {
return func(result *v1beta1.TaskResult) {
r := &v1beta1.TaskResult{
Name: name,
Description: desc,
}
for _, op := range ops {
op(r)
}
}
}

// TaskInputs sets inputs to the TaskSpec.
// Any number of Inputs modifier can be passed to transform it.
func TaskInputs(ops ...InputsOp) TaskSpecOp {
Expand Down

0 comments on commit d8ddbde

Please sign in to comment.