@@ -21,7 +21,7 @@ import (
21
21
"time"
22
22
23
23
"github.com/jonboulle/clockwork"
24
- tb "github.com/tektoncd/cli/internal/builder/v1alpha1"
24
+
25
25
"github.com/tektoncd/cli/pkg/test"
26
26
cb "github.com/tektoncd/cli/pkg/test/builder"
27
27
testDynamic "github.com/tektoncd/cli/pkg/test/dynamic"
@@ -32,7 +32,6 @@ import (
32
32
corev1 "k8s.io/api/core/v1"
33
33
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34
34
"k8s.io/client-go/dynamic"
35
- "knative.dev/pkg/apis"
36
35
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
37
36
)
38
37
@@ -41,50 +40,82 @@ func TestPipelineDelete(t *testing.T) {
41
40
clock := clockwork .NewFakeClock ()
42
41
43
42
pdata := []* v1alpha1.Pipeline {
44
- tb .Pipeline ("pipeline" ,
45
- tb .PipelineNamespace ("ns" ),
46
- // created 5 minutes back
47
- cb .PipelineCreationTimestamp (clock .Now ().Add (- 5 * time .Minute )),
48
- ),
49
- tb .Pipeline ("pipeline2" ,
50
- tb .PipelineNamespace ("ns" ),
51
- // created 5 minutes back
52
- cb .PipelineCreationTimestamp (clock .Now ().Add (- 5 * time .Minute )),
53
- ),
43
+ {
44
+ ObjectMeta : metav1.ObjectMeta {
45
+ Name : "pipeline" ,
46
+ Namespace : "ns" ,
47
+ // created 5 minutes back
48
+ CreationTimestamp : metav1.Time {Time : clock .Now ().Add (- 5 * time .Minute )},
49
+ },
50
+ },
51
+ {
52
+ ObjectMeta : metav1.ObjectMeta {
53
+ Name : "pipeline2" ,
54
+ Namespace : "ns" ,
55
+ // created 5 minutes back
56
+ CreationTimestamp : metav1.Time {Time : clock .Now ().Add (- 5 * time .Minute )},
57
+ },
58
+ },
54
59
}
55
60
prdata := []* v1alpha1.PipelineRun {
56
- tb .PipelineRun ("pipeline-run-1" ,
57
- tb .PipelineRunNamespace ("ns" ),
58
- cb .PipelineRunCreationTimestamp (clock .Now ()),
59
- tb .PipelineRunLabel ("tekton.dev/pipeline" , "pipeline" ),
60
- tb .PipelineRunSpec ("pipeline" ),
61
- tb .PipelineRunStatus (
62
- tb .PipelineRunStatusCondition (apis.Condition {
63
- Status : corev1 .ConditionTrue ,
64
- Reason : v1beta1 .PipelineRunReasonSuccessful .String (),
65
- }),
66
- // pipeline run starts now
67
- tb .PipelineRunStartTime (clock .Now ()),
68
- // takes 10 minutes to complete
69
- cb .PipelineRunCompletionTime (clock .Now ().Add (10 * time .Minute )),
70
- ),
71
- ),
72
- tb .PipelineRun ("pipeline-run-2" ,
73
- tb .PipelineRunNamespace ("ns" ),
74
- cb .PipelineRunCreationTimestamp (clock .Now ()),
75
- tb .PipelineRunLabel ("tekton.dev/pipeline" , "pipeline" ),
76
- tb .PipelineRunSpec ("pipeline" ),
77
- tb .PipelineRunStatus (
78
- tb .PipelineRunStatusCondition (apis.Condition {
79
- Status : corev1 .ConditionTrue ,
80
- Reason : v1beta1 .PipelineRunReasonSuccessful .String (),
81
- }),
82
- // pipeline run starts now
83
- tb .PipelineRunStartTime (clock .Now ()),
84
- // takes 10 minutes to complete
85
- cb .PipelineRunCompletionTime (clock .Now ().Add (10 * time .Minute )),
86
- ),
87
- ),
61
+ {
62
+ ObjectMeta : metav1.ObjectMeta {
63
+ Name : "pipeline-run-1" ,
64
+ Namespace : "ns" ,
65
+ CreationTimestamp : metav1.Time {Time : clock .Now ()},
66
+ Labels : map [string ]string {"tekton.dev/pipeline" : "pipeline" },
67
+ },
68
+ Spec : v1alpha1.PipelineRunSpec {
69
+ PipelineRef : & v1alpha1.PipelineRef {
70
+ Name : "pipeline" ,
71
+ },
72
+ },
73
+ Status : v1alpha1.PipelineRunStatus {
74
+ Status : duckv1beta1.Status {
75
+ Conditions : duckv1beta1.Conditions {
76
+ {
77
+ Status : corev1 .ConditionTrue ,
78
+ Reason : v1beta1 .PipelineRunReasonSuccessful .String (),
79
+ },
80
+ },
81
+ },
82
+ PipelineRunStatusFields : v1alpha1.PipelineRunStatusFields {
83
+ // pipeline run starts now
84
+ StartTime : & metav1.Time {Time : clock .Now ()},
85
+ // takes 10 minutes to complete
86
+ CompletionTime : & metav1.Time {Time : clock .Now ().Add (10 * time .Minute )},
87
+ },
88
+ },
89
+ },
90
+ {
91
+ ObjectMeta : metav1.ObjectMeta {
92
+ Name : "pipeline-run-2" ,
93
+ Namespace : "ns" ,
94
+ Labels : map [string ]string {"tekton.dev/pipeline" : "pipeline" },
95
+ CreationTimestamp : metav1.Time {Time : clock .Now ()},
96
+ },
97
+ Spec : v1alpha1.PipelineRunSpec {
98
+ PipelineRef : & v1alpha1.PipelineRef {
99
+ Name : "pipeline" ,
100
+ },
101
+ },
102
+ Status : v1alpha1.PipelineRunStatus {
103
+ Status : duckv1beta1.Status {
104
+ Conditions : duckv1beta1.Conditions {
105
+ {
106
+ Status : corev1 .ConditionTrue ,
107
+ Reason : v1beta1 .PipelineRunReasonSuccessful .String (),
108
+ },
109
+ },
110
+ },
111
+ PipelineRunStatusFields : v1alpha1.PipelineRunStatusFields {
112
+ // pipeline run starts now
113
+ StartTime : & metav1.Time {Time : clock .Now ()},
114
+ // takes 10 minutes to complete
115
+ CompletionTime : & metav1.Time {Time : clock .Now ().Add (10 * time .Minute )},
116
+ },
117
+ },
118
+ },
88
119
}
89
120
type clients struct {
90
121
pipelineClient pipelinetest.Clients
0 commit comments