Skip to content

Commit

Permalink
test: attach location image to struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaanqui committed Apr 29, 2024
1 parent 7e9eb0f commit d3595ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Binary file added tests/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions tests/scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package tests

import (
"fmt"
"os"
"testing"
"time"

"github.com/99designs/gqlgen/graphql"
"github.com/stadio-app/stadio-backend/database/jet/postgres/public/model"
"github.com/stadio-app/stadio-backend/graph/gmodel"
)
Expand Down Expand Up @@ -60,6 +62,11 @@ func TestLocation(t *testing.T) {
}
var location gmodel.Location

file, err := os.Open("./img.png")
if err != nil {
t.Fatal(err)
}

t.Run("create location", func(t *testing.T) {
input := gmodel.CreateLocation{
Name: "My Soccer Field",
Expand All @@ -77,6 +84,16 @@ func TestLocation(t *testing.T) {
Instances: []*gmodel.CreateLocationInstance{
{Name: "Field #1"},
},
Images: []*gmodel.CreateLocationImage{
{
File: graphql.Upload{
File: file,
Filename: file.Name(),
ContentType: "image/png",
},
Default: true,
},
},
}
if location, err = service.CreateLocation(ctx, &user, input); err != nil {
t.Fatal(err.Error())
Expand Down Expand Up @@ -333,6 +350,16 @@ func TestLocation(t *testing.T) {
},
Schedule: init_schedule(7, 20, true), // 7am - 8pm
Instances: init_location_instances(num_instances),
Images: []*gmodel.CreateLocationImage{
{
File: graphql.Upload{
File: file,
Filename: file.Name(),
ContentType: "image/png",
},
Default: true,
},
},
})
if err != nil {
t.Fatal("could not create complex location")
Expand Down

0 comments on commit d3595ee

Please sign in to comment.