Skip to content

Commit

Permalink
update/add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabemontero committed Jun 28, 2021
1 parent d43675b commit 7112af9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/integration/buildruns_to_taskruns_test.go
Expand Up @@ -357,7 +357,7 @@ var _ = Describe("Integration tests BuildRuns and TaskRuns", func() {
})
})

Context("when a buildrun is created and cancelled", func() {
Context("when a buildrun is created and the taskrun is cancelled", func() {

BeforeEach(func() {
buildSample = []byte(test.BuildCBSMinimal)
Expand Down Expand Up @@ -390,6 +390,39 @@ var _ = Describe("Integration tests BuildRuns and TaskRuns", func() {
})
})

Context("when a buildrun is created and the buildrun is cancelled", func() {

BeforeEach(func() {
buildSample = []byte(test.BuildCBSMinimal)
buildRunSample = []byte(test.MinimalBuildRun)
})

It("should reflect a TaskRunCancelled reason in the taskrun, BuildRunCanceled in the buildrun, and no completionTime", func() {

Expect(tb.CreateBuild(buildObject)).To(BeNil())

buildObject, err = tb.GetBuildTillValidation(buildObject.Name)
Expect(err).To(BeNil())

Expect(tb.CreateBR(buildRunObject)).To(BeNil())

bro, err := tb.GetBRTillStartTime(buildRunObject.Name)
Expect(err).To(BeNil())

bro.Spec.Status = v1alpha1.BuildRunSpecStatusCanceled
err = tb.UpdateBR(bro)
Expect(err).To(BeNil())

expectedReason := "TaskRunCancelled"
actualReason, err := tb.GetTRTillDesiredReason(buildRunObject.Name, expectedReason)
Expect(err).To(BeNil(), fmt.Sprintf("failed to get desired TaskRun reason; expected %s, got %s", expectedReason, actualReason))

expectedReason = v1alpha1.BuildRunSpecStatusCanceled
actualReason, err = tb.GetBRTillDesiredReason(buildRunObject.Name, expectedReason)
Expect(err).To(BeNil(), fmt.Sprintf("failed to get desired BuildRun reason; expected %s, got %s", expectedReason, actualReason))
})
})

Context("when a buildrun is created and the taskrun deleted before completion", func() {

BeforeEach(func() {
Expand Down
10 changes: 10 additions & 0 deletions test/utils/buildruns.go
Expand Up @@ -30,6 +30,16 @@ func (t *TestBuild) CreateBR(buildRun *v1alpha1.BuildRun) error {
return nil
}

// UpdateBR updates a BuildRun on the current test namespace
func (t *TestBuild) UpdateBR(buildRun *v1alpha1.BuildRun) error {
brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace)
_, err := brInterface.Update(context.TODO(), buildRun, metav1.UpdateOptions{})
if err != nil {
return err
}
return nil
}

// GetBR retrieves a BuildRun from a desired namespace
// Deprecated: Use LookupBuildRun instead.
func (t *TestBuild) GetBR(name string) (*v1alpha1.BuildRun, error) {
Expand Down

0 comments on commit 7112af9

Please sign in to comment.