@@ -380,65 +380,67 @@ func TestStateBuilding(t *testing.T) {
380380 setup (g )
381381 runSuccessfulBuild (g , client , ctx , reconciler , taskRunName )
382382
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 ())
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())
392+ //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}}))
392395 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 )
396396 g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateComplete ))
397397
398398 g .Expect (db .Status .DeployedArtifacts ).Should (ContainElement (TestArtifact ))
399399 ra := v1alpha1.RebuiltArtifact {}
400400 g .Expect (client .Get (ctx , types.NamespacedName {Name : artifactbuild .CreateABRName (TestArtifact ), Namespace : metav1 .NamespaceDefault }, & ra )).Should (Succeed ())
401401 g .Expect (ra .Spec .GAV ).Should (Equal (TestArtifact ))
402402 g .Expect (ra .Spec .Image ).ShouldNot (BeNil ())
403- pr = getBuildPipeline (client , g )
403+ pr : = getBuildPipeline (client , g )
404404 g .Expect (len (pr .Finalizers )).Should (Equal (1 ))
405405
406406 g .Expect (client .Delete (ctx , pr )).Should (BeNil ())
407407 g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Namespace : db .Namespace , Name : pr .Name }}))
408408 g .Expect (client .Get (ctx , types.NamespacedName {Name : pr .Name , Namespace : pr .Namespace }, pr )).ShouldNot (Succeed ())
409409 })
410+ // TODO: ### Either remove or replace with verification step *but* the contaminants/verification is all tied to the build pipeline in dependencybuild.go
411+ /*
412+ t.Run("Test reconcile building DependencyBuild with failed deploy pipeline", func(t *testing.T) {
413+ g := NewGomegaWithT(t)
414+ setup(g)
415+ runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
416+
417+ pr := getDeployPipeline(client, g)
418+ pr.Status.CompletionTime = &metav1.Time{Time: time.Now()}
419+ pr.Status.SetCondition(&apis.Condition{
420+ Type: apis.ConditionSucceeded,
421+ Status: "False",
422+ LastTransitionTime: apis.VolatileTime{Inner: metav1.Time{Time: time.Now()}},
423+ })
424+ g.Expect(client.Status().Update(ctx, pr)).Should(BeNil())
425+ g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
426+ db := getBuild(client, g)
427+ g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
410428
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 ()}},
422429 })
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 ))
427430
428- })
431+ t.Run("Test reconcile building DependencyBuild with deleted deploy pipeline", func(t *testing.T) {
432+ g := NewGomegaWithT(t)
433+ setup(g)
434+ runSuccessfulBuild(g, client, ctx, reconciler, taskRunName)
429435
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 )
436+ pr := getDeployPipeline(client, g)
437+ g.Expect(client.Delete(ctx, pr)).Should(Succeed())
438+ g.Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: pr.Name, Namespace: pr.Namespace}}))
439+ db := getBuild(client, g)
440+ g.Expect(db.Status.State).Should(Equal(v1alpha1.DependencyBuildStateFailed))
434441
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- })
442+ })
443+ */
442444 t .Run ("Test reconcile building DependencyBuild with failed pipeline" , func (t * testing.T ) {
443445 g := NewGomegaWithT (t )
444446 setup (g )
@@ -583,7 +585,7 @@ func runSuccessfulBuild(g *WithT, client runtimeclient.Client, ctx context.Conte
583585 g .Expect (client .Status ().Update (ctx , pr )).Should (BeNil ())
584586 g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : taskRunName }))
585587 db := getBuild (client , g )
586- g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateDeploying ))
588+ g .Expect (db .Status .State ).Should (Equal (v1alpha1 .DependencyBuildStateComplete ))
587589 g .Expect (reconciler .Reconcile (ctx , reconcile.Request {NamespacedName : types.NamespacedName {Name : db .Name , Namespace : db .Namespace }}))
588590}
589591
0 commit comments