Skip to content

Commit

Permalink
test: verify image details insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaanqui committed Apr 29, 2024
1 parent d3595ee commit 99d2608
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions services/location_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (service Service) CreateLocation(ctx context.Context, user *gmodel.User, in
return gmodel.Location{}, err
}

// upload and store images
_, err = service.BulkCreateLocationImages(ctx, location.ID, user, input.Images)
// store image information
location.LocationImages, err = service.BulkCreateLocationImages(ctx, location.ID, user, input.Images)
if err != nil {
tx.Rollback()
return gmodel.Location{}, err
Expand Down
7 changes: 7 additions & 0 deletions tests/scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/99designs/gqlgen/graphql"
"github.com/google/uuid"
"github.com/stadio-app/stadio-backend/database/jet/postgres/public/model"
"github.com/stadio-app/stadio-backend/graph/gmodel"
)
Expand Down Expand Up @@ -101,6 +102,12 @@ func TestLocation(t *testing.T) {
if len(location.LocationSchedule) != len(input.Schedule) {
t.Fatal("location.location_schedule and schedule must have the same number of values")
}
if len(location.LocationImages) != len(input.Images) {
t.Fatal("not all images were inserted")
}
if _, err := uuid.Parse(location.LocationImages[0].UploadID); err != nil {
t.Fatal("location_image.upload_id is not a valid UUID", err)
}

for i, schedule := range location.LocationSchedule {
schedule_input := input.Schedule[i]
Expand Down

0 comments on commit 99d2608

Please sign in to comment.