@@ -287,12 +287,14 @@ func getBuildPipelineNo(client runtimeclient.Client, g *WithT, no int) *tektonpi
287287 return & build
288288}
289289
290+ /*
290291func getDeployPipeline(client runtimeclient.Client, g *WithT) *tektonpipeline.PipelineRun {
291292 ctx := context.TODO()
292293 build := tektonpipeline.PipelineRun{}
293294 g.Expect(client.Get(ctx, types.NamespacedName{Namespace: metav1.NamespaceDefault, Name: "test-deploy"}, &build)).Should(BeNil())
294295 return &build
295296}
297+ */
296298
297299func getBuildInfoPipeline (client runtimeclient.Client , g * WithT ) * tektonpipeline.PipelineRun {
298300 return getBuildInfoPipelineNo (client , g , 0 )
@@ -380,65 +382,67 @@ func TestStateBuilding(t *testing.T) {
380382 setup (g )
381383 runSuccessfulBuild (g , client , ctx , reconciler , taskRunName )
382384
383- pr := getDeployPipeline (client , g )
384- pr .Status .CompletionTime = & metav1.Time {Time : time .Now ()}
385- pr .Status .SetCondition (& apis.Condition {
386- Type : apis .ConditionSucceeded ,
387- Status : "True" ,
388- LastTransitionTime : apis.VolatileTime {Inner : metav1.Time {Time : time .Now ()}},
389- })
390- pr .Status .Results = []tektonpipeline.PipelineRunResult {{Name : PipelineResultDeployedResources , Value : tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : TestArtifact }}}
391- g .Expect (client .Status ().Update (ctx , pr )).Should (BeNil ())
385+ //pr := getDeployPipeline(client, g)
386+ //pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
387+ //pr.Status.SetCondition(&apis.Condition{
388+ // Type: apis.ConditionSucceeded,
389+ // Status: "True",
390+ // LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
391+ //})
392+ //pr.Status.Results = []tektonpipeline.PipelineRunResult{{Name: PipelineResultDeployedResources, Value: tektonpipeline.ResultValue{Type: tektonpipeline.ParamTypeString, StringVal: TestArtifact}}}
393+ //g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
394+ //db := getBuild(client, g)
395+ //g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
396+ //g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: db.Name, Namespace: db.Namespace}}))
392397 db := getBuild (client , g )
393- g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Name : pr .Name , Namespace : pr .Namespace }}))
394- g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Name : db .Name , Namespace : db .Namespace }}))
395- db = getBuild (client , g )
396398 g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateComplete ))
397399
398400 g .Expect (db .Status .DeployedArtifacts ).Should (ContainElement (TestArtifact ))
399401 ra := v1alpha1.RebuiltArtifact {}
400402 g .Expect (client .Get (ctx , types.NamespacedName {Name : artifactbuild .CreateABRName (TestArtifact ), Namespace : metav1 .NamespaceDefault }, & ra )).Should (Succeed ())
401403 g .Expect (ra .Spec .GAV ).Should (Equal (TestArtifact ))
402404 g .Expect (ra .Spec .Image ).ShouldNot (BeNil ())
403- pr = getBuildPipeline (client , g )
405+ pr : = getBuildPipeline (client , g )
404406 g .Expect (len (pr .Finalizers )).Should (Equal (1 ))
405407
406408 g .Expect (client .Delete (ctx , pr )).Should (BeNil ())
407409 g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Namespace : db .Namespace , Name : pr .Name }}))
408410 g .Expect (client .Get (ctx , types.NamespacedName {Name : pr .Name , Namespace : pr .Namespace }, pr )).ShouldNot (Succeed ())
409411 })
412+ // TODO: ### Either remove or replace with verification step *but* the contaminants/verification is all tied to the build pipeline in dependencybuild.go
413+ /*
414+ t.Run("Test reconcile building DependencyBuild with failed deploy pipeline", func(t *testing.T) {
415+ g := NewGomegaWithT(t)
416+ setup(g)
417+ runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
418+
419+ pr := getDeployPipeline(client, g)
420+ pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
421+ pr.Status.SetCondition(&apis.Condition{
422+ Type: apis.ConditionSucceeded,
423+ Status: "False",
424+ LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
425+ })
426+ g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
427+ g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
428+ db := getBuild(client, g)
429+ g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
410430
411- t .Run ("Test reconcile building DependencyBuild with failed deploy pipeline" , func (t * testing.T ) {
412- g := NewGomegaWithT (t )
413- setup (g )
414- runSuccessfulBuild (g , client , ctx , reconciler , taskRunName )
415-
416- pr := getDeployPipeline (client , g )
417- pr .Status .CompletionTime = & metav1.Time {Time : time .Now ()}
418- pr .Status .SetCondition (& apis.Condition {
419- Type : apis .ConditionSucceeded ,
420- Status : "False" ,
421- LastTransitionTime : apis.VolatileTime {Inner : metav1.Time {Time : time .Now ()}},
422431 })
423- g .Expect (client .Status ().Update (ctx , pr )).Should (BeNil ())
424- g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Name : pr .Name , Namespace : pr .Namespace }}))
425- db := getBuild (client , g )
426- g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateFailed ))
427432
428- })
433+ t.Run("Test reconcile building DependencyBuild with deleted deploy pipeline", func(t *testing.T) {
434+ g := NewGomegaWithT(t)
435+ setup(g)
436+ runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
429437
430- t .Run ("Test reconcile building DependencyBuild with deleted deploy pipeline" , func (t * testing.T ) {
431- g := NewGomegaWithT (t )
432- setup (g )
433- runSuccessfulBuild (g , client , ctx , reconciler , taskRunName )
438+ pr := getDeployPipeline(client, g)
439+ g.Expect(client.Delete(ctx, pr)).Should(Succeed())
440+ g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
441+ db := getBuild(client, g)
442+ g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
434443
435- pr := getDeployPipeline (client , g )
436- g .Expect (client .Delete (ctx , pr )).Should (Succeed ())
437- g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Name : pr .Name , Namespace : pr .Namespace }}))
438- db := getBuild (client , g )
439- g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateFailed ))
440-
441- })
444+ })
445+ */
442446 t .Run ("Test reconcile building DependencyBuild with failed pipeline" , func (t * testing.T ) {
443447 g := NewGomegaWithT (t )
444448 setup (g )
@@ -583,7 +587,7 @@ func runSuccessfulBuild(g *WithT, client runtimeclient.Client, ctx context.Conte
583587 g .Expect (client .Status ().Update (ctx , pr )).Should (BeNil ())
584588 g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : taskRunName }))
585589 db := getBuild (client , g )
586- g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateDeploying ))
590+ g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateComplete ))
587591 g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Name : db .Name , Namespace : db .Namespace }}))
588592}
589593
0 commit comments