Skip to content

Commit

Permalink
Add timeouts tests for v1beta1 PipelineRun Defaults
Browse files Browse the repository at this point in the history
This commit adds the timeouts defaults for v1beta1 PipelineRun
defaults. It aims to increase the coverage of the pipelineRun timeouts
defaults in v1beta1.
  • Loading branch information
JeromeJu committed Apr 17, 2023
1 parent d027195 commit eaa67d1
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion pkg/apis/pipeline/v1beta1/pipelinerun_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/tektoncd/pipeline/pkg/apis/config"
cfgtesting "github.com/tektoncd/pipeline/pkg/apis/config/testing"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/pod"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/test/diff"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -55,6 +55,55 @@ func TestPipelineRunSpec_SetDefaults(t *testing.T) {
ServiceAccountName: config.DefaultServiceAccountValue,
Timeout: &metav1.Duration{Duration: 500 * time.Millisecond},
},
}, {
desc: "timeouts is nil",
prs: &v1beta1.PipelineRunSpec{},
want: &v1beta1.PipelineRunSpec{
ServiceAccountName: config.DefaultServiceAccountValue,
Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute},
},
},
{
desc: "timeouts is not nil",
prs: &v1beta1.PipelineRunSpec{
Timeouts: &v1beta1.TimeoutFields{},
},
want: &v1beta1.PipelineRunSpec{
ServiceAccountName: config.DefaultServiceAccountValue,
Timeouts: &v1beta1.TimeoutFields{
Pipeline: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute},
},
},
},
{
desc: "timeouts.pipeline is not nil",
prs: &v1beta1.PipelineRunSpec{
Timeouts: &v1beta1.TimeoutFields{
Pipeline: &metav1.Duration{Duration: (config.DefaultTimeoutMinutes + 1) * time.Minute},
},
},
want: &v1beta1.PipelineRunSpec{
ServiceAccountName: config.DefaultServiceAccountValue,
Timeouts: &v1beta1.TimeoutFields{
Pipeline: &metav1.Duration{Duration: (config.DefaultTimeoutMinutes + 1) * time.Minute},
},
},
}, {
desc: "timeouts.pipeline is nil with timeouts.tasks and timeouts.finally",
prs: &v1beta1.PipelineRunSpec{
Timeouts: &v1beta1.TimeoutFields{
Tasks: &metav1.Duration{Duration: (config.DefaultTimeoutMinutes + 1) * time.Minute},
Finally: &metav1.Duration{Duration: (config.DefaultTimeoutMinutes + 1) * time.Minute},
},
},
want: &v1beta1.PipelineRunSpec{
ServiceAccountName: config.DefaultServiceAccountValue,
Timeouts: &v1beta1.TimeoutFields{
Pipeline: &metav1.Duration{Duration: (config.DefaultTimeoutMinutes) * time.Minute},
Tasks: &metav1.Duration{Duration: (config.DefaultTimeoutMinutes + 1) * time.Minute},
Finally: &metav1.Duration{Duration: (config.DefaultTimeoutMinutes + 1) * time.Minute},
},
},
},
{
desc: "pod template is nil",
Expand Down

0 comments on commit eaa67d1

Please sign in to comment.