Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hantonelli committed Mar 31, 2019
1 parent 2c1f857 commit d377039
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions handler/graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,28 +401,26 @@ func TestProcessMultipart(t *testing.T) {
func TestAddUploadToOperations(t *testing.T) {

t.Run("fail missing all variables", func(t *testing.T) {
file, err := os.Open("path/to/file")
require.Nil(t, err)
file, _ := os.Open("path/to/file")
var operations map[string]interface{}
upload := graphql.Upload{
File: file,
Filename: "a.txt",
Size: int64(5),
}
path := "variables.req.0.file"
err = addUploadToOperations(operations, upload, path)
err := addUploadToOperations(operations, upload, path)
require.NotNil(t, err)
require.Equal(t, "variables is missing, path: variables.req.0.file", err.Error())
})

t.Run("valid variable", func(t *testing.T) {
file, err := os.Open("path/to/file")
file, _ := os.Open("path/to/file")
operations := map[string]interface{}{
"variables": map[string]interface{}{
"file": nil,
},
}
require.Nil(t, err)

upload := graphql.Upload{
File: file,
Expand All @@ -437,15 +435,14 @@ func TestAddUploadToOperations(t *testing.T) {
}

path := "variables.file"
err = addUploadToOperations(operations, upload, path)
err := addUploadToOperations(operations, upload, path)
require.Nil(t, err)

require.Equal(t, operations, expected)
})

t.Run("valid nested variable", func(t *testing.T) {
file, err := os.Open("path/to/file")
require.Nil(t, err)
file, _ := os.Open("path/to/file")
operations := map[string]interface{}{
"variables": map[string]interface{}{
"req": []interface{}{
Expand Down Expand Up @@ -473,7 +470,7 @@ func TestAddUploadToOperations(t *testing.T) {
}

path := "variables.req.0.file"
err = addUploadToOperations(operations, upload, path)
err := addUploadToOperations(operations, upload, path)
require.Nil(t, err)

require.Equal(t, operations, expected)
Expand Down

0 comments on commit d377039

Please sign in to comment.