github.com/newrelic/newrelic-client-go@v1.1.0/pkg/apiaccess/insights_keys_integration_test.go (about)

     1  package apiaccess
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	mock "github.com/newrelic/newrelic-client-go/pkg/testhelpers"
     9  )
    10  
    11  func TestIntegrationAPIAccess_InsightsInsertKeys(t *testing.T) {
    12  	t.Parallel()
    13  	t.Skip("For manual use only.")
    14  
    15  	testAccountID, err := mock.GetTestAccountID()
    16  	if err != nil {
    17  		t.Skipf("%s", err)
    18  	}
    19  
    20  	client := newIntegrationTestClient(t)
    21  
    22  	// Test: Create
    23  	createResult, err := client.CreateInsightsInsertKey(testAccountID)
    24  	require.NoError(t, err)
    25  	require.NotZero(t, createResult)
    26  
    27  	// Test: List
    28  	listResult, err := client.ListInsightsInsertKeys(testAccountID)
    29  	require.NoError(t, err)
    30  	require.Greater(t, len(listResult), 0)
    31  
    32  	// Test: Get
    33  	getResult, err := client.GetInsightsInsertKey(testAccountID, listResult[0].ID)
    34  	require.NoError(t, err)
    35  	require.NotZero(t, getResult)
    36  
    37  	// Test: Delete
    38  	updateResult, err := client.DeleteInsightsInsertKey(testAccountID, getResult.ID)
    39  	require.NoError(t, err)
    40  	require.NotNil(t, updateResult)
    41  
    42  }
    43  
    44  func TestIntegrationAPIAccess_InsightsQueryKeys(t *testing.T) {
    45  	t.Parallel()
    46  	t.Skip("For manual use only.")
    47  
    48  	testAccountID, err := mock.GetTestAccountID()
    49  	if err != nil {
    50  		t.Skipf("%s", err)
    51  	}
    52  
    53  	client := newIntegrationTestClient(t)
    54  
    55  	// Test: Create
    56  	createResult, err := client.CreateInsightsQueryKey(testAccountID)
    57  	require.NoError(t, err)
    58  	require.NotZero(t, createResult)
    59  
    60  	// Test: List
    61  	listResult, err := client.ListInsightsQueryKeys(testAccountID)
    62  	require.NoError(t, err)
    63  	require.Greater(t, len(listResult), 0)
    64  
    65  	// Test: Get
    66  	getResult, err := client.GetInsightsQueryKey(testAccountID, listResult[0].ID)
    67  	require.NoError(t, err)
    68  	require.NotZero(t, getResult)
    69  
    70  	// Test: Delete
    71  	deleteResult, err := client.DeleteInsightsQueryKey(testAccountID, getResult.ID)
    72  	require.NoError(t, err)
    73  	require.NotNil(t, deleteResult)
    74  }
    75  
    76  //nolint: unused
    77  func newIntegrationTestClient(t *testing.T) APIAccess {
    78  	tc := mock.NewIntegrationTestConfig(t)
    79  
    80  	return New(tc)
    81  }