Skip to content

Commit

Permalink
Errors handling
Browse files Browse the repository at this point in the history
Signed-off-by: Maayan Hadasi <mguetta@redhat.com>
  • Loading branch information
mguetta1 committed Sep 18, 2023
1 parent e7f1ad8 commit f41bc63
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"RETRY_NUM": "10"
"RETRY_NUM": "10",
"KEEP": "0"
}
1 change: 1 addition & 0 deletions config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ type Configuration struct {
JIRA_PASSWORD string `env:"JIRA_PASSWORD"`
JIRA_URL string `env:"JIRA_URL"`
RETRY_NUM string `env:"RETRY_NUM"`
KEEP string `env:"KEEP"`
}
10 changes: 6 additions & 4 deletions e2e/jiraintegration/jira_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ const (

var _ = Describe("Jira Connection", Ordered, func() {
AfterAll(func() {
// Resources cleanup
// Delete tracker instance and the associated identity after

//TODO - error handling
Tracker.Delete(jiraInstance.ID)
Identity.Delete(jiraBasicAuth.ID)
if keep, _ := strconv.ParseBool(Config.KEEP); keep {
return
}
Expect(Tracker.Delete(jiraInstance.ID)).To(Succeed())
Expect(Identity.Delete(jiraBasicAuth.ID)).To(Succeed())
})

Context("Create new Jira instance", func() {
Expand Down
8 changes: 7 additions & 1 deletion e2e/metrics/application_metrics.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package metrics

import (
"strconv"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/konveyor/go-konveyor-tests/config"
"github.com/konveyor/go-konveyor-tests/utils"
"github.com/konveyor/tackle2-hub/api"
)
Expand All @@ -23,6 +26,9 @@ var _ = Describe("Application Metrics", Ordered, func() {

AfterAll(func() {
// Resources cleanup
if keep, _ := strconv.ParseBool(Config.KEEP); keep {
return
}
utils.DeleteApplicationsBySlice(apps)
})

Expand All @@ -39,7 +45,7 @@ var _ = Describe("Application Metrics", Ordered, func() {
It("Should decrease the applications gauge", func() {
// Delete the last application item
lastApplicationItem := apps[len(apps)-1]
Application.Delete(lastApplicationItem.ID)
utils.DeleteApplicationsBySlice([]api.Application{lastApplicationItem})
metricValue--
Expect(GetMetricValue(metricName)).To(Equal(metricValue))
})
Expand Down
7 changes: 4 additions & 3 deletions utils/application_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/konveyor/go-konveyor-tests/data"
"github.com/konveyor/go-konveyor-tests/hack/uniq"
"github.com/konveyor/tackle2-hub/api"
. "github.com/onsi/gomega"
)

func CreateMultipleApplications(numberOfApplications int) []api.Application {
Expand All @@ -17,15 +18,15 @@ func CreateMultipleApplications(numberOfApplications int) []api.Application {
//// Create a local copy
application := data.ApplicationSamples[randomIndex]
uniq.ApplicationName(&application)
//// TODO: dealing with create returns error
Application.Create(&application)
Expect(Application.Create(&application)).To(Succeed())
appSlice = append(appSlice, application)
}
return appSlice
}

func DeleteApplicationsBySlice(apps []api.Application) {
for i := 0; i < len(apps); i++ {
Application.Delete(apps[i].ID)
Expect(Application.Delete(apps[i].ID)).To(Succeed())
return
}
}

0 comments on commit f41bc63

Please sign in to comment.