Skip to content

Commit

Permalink
Use test builders and fix providedBy example 👷♀️
Browse files Browse the repository at this point in the history
In tektoncd#342 I added docs and
validation for the `providedBy` field, but I missed some feedback from
@vdemeester before the PR was merged, so I'm addressing it now!

The change to use the builders, even just for `PipelineResources`,
removes a surprising amount of boilerplate! It doesn't seem like I can
really use the builders for constructing the `state` object (slice of
`ResolvedPipelineRunTask`) unless we add builder for
`ResolvedPipelineRunTask`. That might be a good idea, however I'm
planning to iterate on some of this for tektoncd#320 and tektoncd#168 (maybe) so I'm
inclined to wait - open to other ideas tho!
  • Loading branch information
bobcatfish committed Jan 3, 2019
1 parent a50349c commit f84198b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
1 change: 1 addition & 0 deletions docs/using.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ This is the corresponding `PipelineRun` spec:
name: skaffold-image-leeroy-app
- name: deploy-app
...
inputs:
- name: image
resourceRef:
name: skaffold-image-leeroy-app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/knative/build-pipeline/pkg/reconciler/v1alpha1/taskrun/resources"
tb "github.com/knative/build-pipeline/test/builder"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -563,14 +564,7 @@ func TestGetPipelineConditionStatus(t *testing.T) {
}

func TestValidateProvidedBy(t *testing.T) {
r := &v1alpha1.PipelineResource{
ObjectMeta: metav1.ObjectMeta{
Name: "holygrail",
},
Spec: v1alpha1.PipelineResourceSpec{
Type: v1alpha1.PipelineResourceTypeImage,
},
}
r := tb.PipelineResource("holygrail", namespace, tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage))
state := []*ResolvedPipelineRunTask{{
PipelineTask: &v1alpha1.PipelineTask{
Name: "quest",
Expand Down Expand Up @@ -616,22 +610,8 @@ func TestValidateProvidedBy(t *testing.T) {
}

func TestValidateProvidedBy_Invalid(t *testing.T) {
r := &v1alpha1.PipelineResource{
ObjectMeta: metav1.ObjectMeta{
Name: "holygrail",
},
Spec: v1alpha1.PipelineResourceSpec{
Type: v1alpha1.PipelineResourceTypeImage,
},
}
otherR := &v1alpha1.PipelineResource{
ObjectMeta: metav1.ObjectMeta{
Name: "holyhandgrenade",
},
Spec: v1alpha1.PipelineResourceSpec{
Type: v1alpha1.PipelineResourceTypeImage,
},
}
r := tb.PipelineResource("holygrail", namespace, tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage))
otherR := tb.PipelineResource("holyhandgrenade", namespace, tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage))

for _, tc := range []struct {
name string
Expand Down

0 comments on commit f84198b

Please sign in to comment.