Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Stabilize API tests #554

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
DISCONNECTED=1 make run &
sleep 15 # probably a dirty solution
HUB_BASE_URL=http://localhost:8080 make test-api
HUB_BASE_URL=http://localhost:8080 make test-api # Intentionaly run 2x to catch data left in Hub DB.

test-e2e:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ jobs:
DISCONNECTED=1 make run &
sleep 15 # probably a dirty solution
HUB_BASE_URL=http://localhost:8080 make test-api
HUB_BASE_URL=http://localhost:8080 make test-api # Intentionaly run 2x to catch data left in Hub DB.
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
Loading