Skip to content

Commit

Permalink
tests(workflows): update test case to use notifcations package client…
Browse files Browse the repository at this point in the history
… in integration test
  • Loading branch information
sanderblue committed Aug 23, 2022
1 parent 04046e0 commit 9d5489a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
11 changes: 6 additions & 5 deletions pkg/workflows/workflows_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
}
15 changes: 5 additions & 10 deletions pkg/workflows/workflows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
}

0 comments on commit 9d5489a

Please sign in to comment.