Skip to content

Commit

Permalink
Merge pull request #283 from MartinBasti/test_reports_base
Browse files Browse the repository at this point in the history
feat(STONEINTG-523): enum for integration test status
  • Loading branch information
MartinBasti committed Aug 24, 2023
2 parents c855fe6 + 17bfc73 commit 6b140fa
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 1 deletion.
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ignore:
- "api/v1alpha1/zz_generated.deepcopy.go" # generated file
- "api/v1beta1/zz_generated.deepcopy.go" # generated file
- "gitops/integrationteststatus_enumer.go" # generated file

coverage:
status:
Expand Down
72 changes: 72 additions & 0 deletions gitops/integrationteststatus_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions gitops/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,25 @@ const (
AppStudioIntegrationStatusFinished = "Finished"
)

// IntegrationTestScenario test runs status
type IntegrationTestStatus int

//go:generate enumer -type=IntegrationTestStatus -linecomment -json
const (
// Nothing is done yet for the ITS list and snapshot
IntegrationTestStatusPending IntegrationTestStatus = iota + 1 // Pending
// Starting to handle an integration test scenario for a snapshot
IntegrationTestStatusInProgress // InProgress
// The environment provision experienced error for this ITS and snapshot
IntegrationTestStatusEnvironmentProvisionError // EnvironmentProvisionError
// The SEB deployment experienced error for this ITS and snapshot
IntegrationTestStatusDeploymentError // DeploymentError
// Integration PLR failed for this ITS and snapshot
IntegrationTestStatusTestFail // TestFail
// Integration PLR passed for this ITS and snapshot
IntegrationTestStatusTestPassed // TestPassed
)

var (
// SnapshotComponentLabel contains the name of the updated Snapshot component - it should match the pipeline label.
SnapshotComponentLabel = tekton.ComponentNameLabel
Expand Down
40 changes: 39 additions & 1 deletion gitops/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"time"

applicationapiv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1"
"github.com/redhat-appstudio/integration-service/gitops"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -333,4 +334,41 @@ var _ = Describe("Gitops functions for managing Snapshots", Ordered, func() {
existingSnapshot := gitops.FindMatchingSnapshot(hasApp, allSnapshots, hasSnapshot)
Expect(existingSnapshot.Name).To(Equal(hasSnapshot.Name))
})

Context("TestStatus type tests", func() {
DescribeTable("Status to string and vice versa",
func(st gitops.IntegrationTestStatus, expectedStr string) {
strRepr := st.String()
Expect(strRepr).To(Equal(expectedStr))
controlStatus, err := gitops.IntegrationTestStatusString(strRepr)
Expect(err).To(BeNil())
Expect(controlStatus).To(Equal(st))
},
Entry("When status is Pending", gitops.IntegrationTestStatusPending, "Pending"),
Entry("When status is InProgress", gitops.IntegrationTestStatusInProgress, "InProgress"),
Entry("When status is EnvironmentProvisionError", gitops.IntegrationTestStatusEnvironmentProvisionError, "EnvironmentProvisionError"),
Entry("When status is DeploymentError", gitops.IntegrationTestStatusDeploymentError, "DeploymentError"),
Entry("When status is TestFail", gitops.IntegrationTestStatusTestFail, "TestFail"),
Entry("When status is TestPass", gitops.IntegrationTestStatusTestPassed, "TestPassed"),
)

DescribeTable("Status to JSON and vice versa",
func(st gitops.IntegrationTestStatus, expectedStr string) {
jsonRepr, err := st.MarshalJSON()
Expect(err).To(BeNil())
Expect(jsonRepr).To(Equal([]byte("\"" + expectedStr + "\"")))

var controlStatus gitops.IntegrationTestStatus
err = controlStatus.UnmarshalJSON(jsonRepr)
Expect(err).To(BeNil())
Expect(controlStatus).To(Equal(st))
},
Entry("When status is Pending", gitops.IntegrationTestStatusPending, "Pending"),
Entry("When status is InProgress", gitops.IntegrationTestStatusInProgress, "InProgress"),
Entry("When status is EnvironmentProvisionError", gitops.IntegrationTestStatusEnvironmentProvisionError, "EnvironmentProvisionError"),
Entry("When status is DeploymentError", gitops.IntegrationTestStatusDeploymentError, "DeploymentError"),
Entry("When status is TestFail", gitops.IntegrationTestStatusTestFail, "TestFail"),
Entry("When status is TestPass", gitops.IntegrationTestStatusTestPassed, "TestPassed"),
)
})
})

0 comments on commit 6b140fa

Please sign in to comment.