github.com/newrelic/newrelic-client-go@v1.1.0/pkg/nerdgraph/nerdgraph_integration_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package nerdgraph 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 11 mock "github.com/newrelic/newrelic-client-go/pkg/testhelpers" 12 ) 13 14 func TestIntegrationQuery(t *testing.T) { 15 t.Parallel() 16 17 client := newNerdGraphIntegrationTestClient(t) 18 19 query := `{ 20 actor { 21 user { 22 email 23 id 24 name 25 } 26 } 27 }` 28 29 variables := map[string]interface{}{} 30 31 actual, err := client.Query(query, variables) 32 33 require.NoError(t, err) 34 require.NotNil(t, actual) 35 } 36 37 func TestIntegrationQueryWithVariables(t *testing.T) { 38 t.Parallel() 39 40 gqlClient := newNerdGraphIntegrationTestClient(t) 41 42 query := ` 43 query($guid: EntityGuid!) { 44 actor { 45 entity(guid: $guid) { 46 guid 47 name 48 domain 49 entityType 50 } 51 } 52 } 53 ` 54 55 variables := map[string]interface{}{ 56 "guid": "MjUyMDUyOHxBUE18QVBQTElDQVRJT058MjE1MDM3Nzk1", 57 } 58 59 actual, err := gqlClient.Query(query, variables) 60 61 require.NoError(t, err) 62 require.NotNil(t, actual) 63 } 64 65 // nolint 66 func newNerdGraphIntegrationTestClient(t *testing.T) NerdGraph { 67 tc := mock.NewIntegrationTestConfig(t) 68 69 return New(tc) 70 }