Skip to content

Commit

Permalink
graphql: add real api test
Browse files Browse the repository at this point in the history
  • Loading branch information
krabiworld committed Jun 12, 2024
1 parent ecbc749 commit 1183e9c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion graphql/graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ func TestHeader(t *testing.T) {
err := client.Run(req, &resp, 1*time.Second)
is.NoErr(err)
is.Equal(calls, 1)

is.Equal(resp.Value, "some data")
}

func TestRealAPI(t *testing.T) {
is := is.New(t)

client := NewClient("https://graphqlzero.almansi.me/api")

req := NewRequest("query {post(id: 1) {id title body}}")
var responseData map[string]interface{}
err := client.Run(req, &responseData, 30*time.Second)
is.NoErr(err)
is.Equal(responseData["post"].(map[string]interface{})["id"], "1")
}

0 comments on commit 1183e9c

Please sign in to comment.