Skip to content

Commit 9f71935

Browse files
committed
qase/lib: fix some checks
Signed-off-by: Loic Devulder <ldevulder@suse.com>
1 parent a160913 commit 9f71935

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

tests/e2e/helpers/qase/qase.go

+38-34
Original file line numberDiff line numberDiff line change
@@ -202,23 +202,26 @@ This function creates a run in a specific project.
202202
- @return ID of the created run
203203
*/
204204
func DeleteRun() {
205+
// Do something only if run id is valid
206+
if runID <= 0 {
207+
logrus.Debug("Nothing to delete!")
208+
return
209+
}
210+
205211
cfg := qase.NewConfiguration()
206212
cfg.AddDefaultHeader("Token", apiToken)
207213
client := qase.NewAPIClient(cfg)
208214

209-
// Do something only if run id is valid
210-
if runID > 0 {
211-
if checkProject(client, projectCode) {
212-
logrus.Debugf("Project %s is validated", projectCode)
215+
if checkProject(client, projectCode) {
216+
logrus.Debugf("Project %s is validated", projectCode)
213217

214-
// Delete test run
215-
deleteRun(client, runID)
216-
logrus.Debugf("Run id %d has been deleted", runID)
218+
// Delete test run
219+
deleteRun(client, runID)
220+
logrus.Debugf("Run id %d has been deleted", runID)
217221

218-
// Check that we can't access the run
219-
if itExists := checkRun(client, runID); itExists {
220-
logrus.Fatalf("Run %d still exists", runID)
221-
}
222+
// Check that we can't access the run
223+
if itExists := checkRun(client, runID); itExists {
224+
logrus.Fatalf("Run %d still exists", runID)
222225
}
223226
}
224227
}
@@ -228,37 +231,38 @@ This function finalises the results for a specific run.
228231
- @return Fatal on error
229232
*/
230233
func FinalizeResults() {
234+
// Do something only if run id is valid
235+
if runID <= 0 {
236+
logrus.Debug("Nothing to finalize!")
237+
return
238+
}
239+
231240
cfg := qase.NewConfiguration()
232241
cfg.AddDefaultHeader("Token", apiToken)
233242
client := qase.NewAPIClient(cfg)
234243

235-
// Do something only if run id is valid
236-
if runID > 0 {
237-
if checkProject(client, projectCode) {
238-
logrus.Debugf("Project %s is validated", projectCode)
239-
240-
// Complete run if needed
241-
if runComplete != "" {
242-
completeRun(client, runID)
244+
if checkProject(client, projectCode) {
245+
logrus.Debugf("Project %s is validated", projectCode)
243246

244-
// Log in Ginkgo
245-
ginkgo.GinkgoWriter.Printf("Report for run ID %d has been complete\n", runID)
246-
}
247+
// Complete run if needed
248+
if runComplete != "" {
249+
completeRun(client, runID)
247250

248-
// Make the run publicly available
249-
if report != "" {
250-
runPublicResponse, _, err := client.RunsApi.UpdateRunPublicity(context.TODO(), qase.RunPublic{Status: true}, projectCode, runID)
251-
if err != nil {
252-
logrus.Fatalf("Error on publishing run: %v", err)
253-
}
254-
logrus.Debugf("Published run available here: %s", runPublicResponse.Result.Url)
251+
// Log in Ginkgo
252+
ginkgo.GinkgoWriter.Printf("Report for run ID %d has been complete\n", runID)
253+
}
255254

256-
// Log in Ginkgo
257-
ginkgo.GinkgoWriter.Printf("Report for run ID %d available: %s\n", runID, runPublicResponse.Result.Url)
255+
// Make the run publicly available
256+
if report != "" {
257+
runPublicResponse, _, err := client.RunsApi.UpdateRunPublicity(context.TODO(), qase.RunPublic{Status: true}, projectCode, runID)
258+
if err != nil {
259+
logrus.Fatalf("Error on publishing run: %v", err)
258260
}
261+
logrus.Debugf("Published run available here: %s", runPublicResponse.Result.Url)
262+
263+
// Log in Ginkgo
264+
ginkgo.GinkgoWriter.Printf("Report for run ID %d available: %s\n", runID, runPublicResponse.Result.Url)
259265
}
260-
} else {
261-
logrus.Debug("Nothing to finalize!")
262266
}
263267
}
264268

@@ -293,7 +297,7 @@ This function creates/updates run/cases for specific Ginkgo tests.
293297
*/
294298
func Qase(id int64, testReport ginkgo.SpecReport) {
295299
// A negative or zero run/case ID means that we won't log anything
296-
if runID == 0 || id <= 0 {
300+
if runID <= 0 || id <= 0 {
297301
return
298302
}
299303

0 commit comments

Comments
 (0)