Skip to content

Commit

Permalink
Stabilize API tests
Browse files Browse the repository at this point in the history
Addressing few issues in hub API tests that cause rare/random failures.
- force serial API test execution (-p=1)
- created data cleanup in Review test

Signed-off-by: Marek Aufart <[email protected]>
  • Loading branch information
aufi committed Nov 10, 2023
1 parent 6171a10 commit 3e695cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test:

# Run Hub REST API tests.
test-api:
HUB_BASE_URL=${HUB_BASE_URL} go test -count=1 -v ./test/api/...
HUB_BASE_URL=${HUB_BASE_URL} go test -count=1 -p=1 -v ./test/api/...

# Run Hub test suite.
test-all: test-unit test-api
Expand Down
12 changes: 6 additions & 6 deletions test/api/review/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ func TestReviewCRUD(t *testing.T) {
// Check if the unchanged values remain same or not.
AssertEqualReviews(t, got, r)

// Delete Related Applications.
assert.Must(t, Application.Delete(app.ID))
// Delete Review.
assert.Must(t, Review.Delete(r.ID))

// Delete Related Applications.
assert.Must(t, Application.Delete(app.ID))

// Check if the review is present even after deletion or not.
_, err = Review.Get(r.ID)
if err == nil {
Expand All @@ -76,9 +77,6 @@ func TestReviewCRUD(t *testing.T) {
destApp := api.Application{
Name: "New Application",
Description: "Application for Review",
Review: &api.Ref{
ID: r.ID,
},
}
assert.Must(t, Application.Create(&destApp))

Expand All @@ -87,7 +85,8 @@ func TestReviewCRUD(t *testing.T) {
t.Errorf(err.Error())
}

gotReview, err := Review.Get(destApp.Review.ID)
destAppRef, _ := Application.Get(destApp.ID)
gotReview, err := Review.Get(destAppRef.Review.ID)
if err != nil {
fmt.Println(err.Error())
t.Errorf(err.Error())
Expand All @@ -98,6 +97,7 @@ func TestReviewCRUD(t *testing.T) {

// Delete Review.
assert.Must(t, Review.Delete(r.ID))
assert.Must(t, Review.Delete(gotReview.ID))

// Delete Applications.
assert.Must(t, Application.Delete(srcApp.ID))
Expand Down

0 comments on commit 3e695cb

Please sign in to comment.