-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding finally type at the pipeline level
these changes are adding finally type and its validation, does not implement this new functionality.
- Loading branch information
1 parent
3554a30
commit ff08a8f
Showing
11 changed files
with
860 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
Copyright 2020 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" | ||
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestPipeline_SetDefaults(t *testing.T) { | ||
cases := []struct { | ||
desc string | ||
p *v1alpha1.Pipeline | ||
want *v1alpha1.Pipeline | ||
}{{ | ||
desc: "empty pipeline", | ||
p: &v1alpha1.Pipeline{}, | ||
want: &v1alpha1.Pipeline{}, | ||
}} | ||
for _, tc := range cases { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
ctx := context.Background() | ||
tc.p.SetDefaults(ctx) | ||
if diff := cmp.Diff(tc.want, tc.p); diff != "" { | ||
t.Errorf("Mismatch of Pipeline: %s", diff) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestPipelineSpec_SetDefaults(t *testing.T) { | ||
cases := []struct { | ||
desc string | ||
ps *v1alpha1.PipelineSpec | ||
want *v1alpha1.PipelineSpec | ||
}{{ | ||
desc: "empty pipelineSpec", | ||
ps: &v1alpha1.PipelineSpec{}, | ||
want: &v1alpha1.PipelineSpec{}, | ||
}, { | ||
desc: "pipeline task - default task kind must be " + string(v1alpha1.NamespacedTaskKind), | ||
ps: &v1alpha1.PipelineSpec{ | ||
Tasks: []v1alpha1.PipelineTask{{ | ||
Name: "foo", TaskRef: &v1alpha1.TaskRef{Name: "foo-task"}, | ||
}}, | ||
}, | ||
want: &v1alpha1.PipelineSpec{ | ||
Tasks: []v1alpha1.PipelineTask{{ | ||
Name: "foo", TaskRef: &v1alpha1.TaskRef{Name: "foo-task", Kind: v1alpha1.NamespacedTaskKind}, | ||
}}, | ||
}, | ||
}, { | ||
desc: "param type - default param type must be " + string(v1alpha1.ParamTypeString), | ||
ps: &v1alpha1.PipelineSpec{ | ||
Params: []v1alpha1.ParamSpec{{ | ||
Name: "string-param", | ||
}}, | ||
}, | ||
want: &v1alpha1.PipelineSpec{ | ||
Params: []v1alpha1.ParamSpec{{ | ||
Name: "string-param", Type: v1alpha1.ParamTypeString, | ||
}}, | ||
}, | ||
}, { | ||
desc: "pipeline task with taskSpec - default param type must be " + string(v1alpha1.ParamTypeString), | ||
ps: &v1alpha1.PipelineSpec{ | ||
Tasks: []v1alpha1.PipelineTask{{ | ||
Name: "foo", TaskSpec: &v1alpha1.TaskSpec{ | ||
TaskSpec: v1beta1.TaskSpec{ | ||
Params: []v1alpha1.ParamSpec{{ | ||
Name: "string-param", | ||
}}, | ||
}, | ||
}, | ||
}}, | ||
}, | ||
want: &v1alpha1.PipelineSpec{ | ||
Tasks: []v1alpha1.PipelineTask{{ | ||
Name: "foo", TaskSpec: &v1alpha1.TaskSpec{ | ||
TaskSpec: v1beta1.TaskSpec{ | ||
Params: []v1alpha1.ParamSpec{{ | ||
Name: "string-param", | ||
Type: v1alpha1.ParamTypeString, | ||
}}, | ||
}, | ||
}, | ||
}}, | ||
}, | ||
}} | ||
for _, tc := range cases { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
ctx := context.Background() | ||
tc.ps.SetDefaults(ctx) | ||
if diff := cmp.Diff(tc.want, tc.ps); diff != "" { | ||
t.Errorf("Mismatch of PipelineSpec: %s", diff) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.