github.com/newrelic/newrelic-client-go@v1.1.0/pkg/installevents/installevents_api_integration_test.go (about) 1 //go:build integration 2 // +build integration 3 4 package installevents 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 TestInstallationCreateRecipeEvent(t *testing.T) { 15 t.Parallel() 16 17 testAccountID, err := mock.GetTestAccountID() 18 if err != nil { 19 t.Skipf("%s", err) 20 } 21 22 client := newIntegrationTestClient(t) 23 24 status := InstallationRecipeStatus{ 25 CliVersion: "0.0.1", 26 Status: InstallationRecipeStatusTypeTypes.AVAILABLE, 27 } 28 29 response, err := client.InstallationCreateRecipeEvent(testAccountID, status) 30 require.NoError(t, err) 31 require.NotNil(t, response) 32 } 33 34 func TestInstallationCreateRecipeEvent_ShouldSendMetadata(t *testing.T) { 35 t.Parallel() 36 37 testAccountID, err := mock.GetTestAccountID() 38 if err != nil { 39 t.Skipf("%s", err) 40 } 41 42 client := newIntegrationTestClient(t) 43 44 status := InstallationRecipeStatus{ 45 CliVersion: "0.0.1", 46 Name: "test", 47 Status: InstallationRecipeStatusTypeTypes.AVAILABLE, 48 Metadata: map[string]interface{}{ 49 "someKey": "some value", 50 }, 51 } 52 53 response, err := client.InstallationCreateRecipeEvent(testAccountID, status) 54 55 require.NoError(t, err) 56 require.NotNil(t, response.Metadata) 57 58 if metaValue, ok := response.Metadata["someKey"].(string); ok { 59 require.Equal(t, "some value", metaValue) 60 } 61 } 62 63 func newIntegrationTestClient(t *testing.T) Installevents { 64 tc := mock.NewIntegrationTestConfig(t) 65 66 return New(tc) 67 }