From 9d5489afdd020aef0e8c8fd5c6d52a2333b8b82c Mon Sep 17 00:00:00 2001 From: Sander Blue Date: Mon, 15 Aug 2022 14:56:29 -0500 Subject: [PATCH] tests(workflows): update test case to use notifcations package client in integration test --- pkg/workflows/workflows_integration_test.go | 11 ++++++----- pkg/workflows/workflows_test.go | 15 +++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/pkg/workflows/workflows_integration_test.go b/pkg/workflows/workflows_integration_test.go index de4023312..694f8fc22 100644 --- a/pkg/workflows/workflows_integration_test.go +++ b/pkg/workflows/workflows_integration_test.go @@ -16,11 +16,12 @@ import ( mock "github.com/newrelic/newrelic-client-go/pkg/testhelpers" ) -func TestMutationWorkflow(t *testing.T) { +func TestWorkflows(t *testing.T) { t.Parallel() n := newIntegrationTestClient(t) - newrelicClient := newrelicIntegrationTestClient(t) + + notificationsClient := newNotificationsIntegrationTestClient(t) accountID, err := mock.GetTestAccountID() if err != nil { @@ -49,7 +50,7 @@ func TestMutationWorkflow(t *testing.T) { destination.Name = fmt.Sprintf("test-notifications-destination-%s", testIntegrationDestinationNameRandStr) // Test: Create Destination - createDestinationResult, err := newrelicClient.Notifications.AiNotificationsCreateDestination(accountID, destination) + createDestinationResult, err := notificationsClient.AiNotificationsCreateDestination(accountID, destination) require.NoError(t, err) require.NotNil(t, createDestinationResult) @@ -72,7 +73,7 @@ func TestMutationWorkflow(t *testing.T) { channel.Name = fmt.Sprintf("test-notifications-channel-%s", testIntegrationChannelNameRandStr) // Test: Create Channel - createChannelResult, err := newrelicClient.Notifications.AiNotificationsCreateChannel(accountID, channel) + createChannelResult, err := notificationsClient.AiNotificationsCreateChannel(accountID, channel) require.NoError(t, err) require.NotNil(t, createChannelResult) @@ -166,7 +167,7 @@ func TestMutationWorkflow(t *testing.T) { require.NotNil(t, deleteResult) // Delete Destination - deleteDestinationResult, err := newrelicClient.notifications.AiNotificationsDeleteDestination(accountID, destinationID) + deleteDestinationResult, err := notificationsClient.AiNotificationsDeleteDestination(accountID, destinationID) require.NoError(t, err) require.NotNil(t, deleteDestinationResult) } diff --git a/pkg/workflows/workflows_test.go b/pkg/workflows/workflows_test.go index c22aec313..f7b2533e7 100644 --- a/pkg/workflows/workflows_test.go +++ b/pkg/workflows/workflows_test.go @@ -6,7 +6,7 @@ package workflows import ( "testing" - "github.com/newrelic/newrelic-client-go/newrelic" + "github.com/newrelic/newrelic-client-go/pkg/notifications" mock "github.com/newrelic/newrelic-client-go/pkg/testhelpers" ) @@ -17,14 +17,9 @@ func newIntegrationTestClient(t *testing.T) Workflows { return client } -func newrelicIntegrationTestClient(t *testing.T) newrelic.NewRelic { - tc := mock.NewIntegrationTestConfig(t) - - client, _ := newrelic.New( - newrelic.ConfigPersonalAPIKey(tc.PersonalAPIKey), - newrelic.ConfigInsightsInsertKey(tc.InsightsInsertKey), - newrelic.ConfigUserAgent(tc.UserAgent), - ) +func newNotificationsIntegrationTestClient(t *testing.T) notifications.Notifications { + cfg := mock.NewIntegrationTestConfig(t) + client := notifications.New(cfg) - return *client + return client }