github.com/newrelic/newrelic-client-go@v1.1.0/pkg/apm/deployments_integration_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  package apm
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func TestIntegrationDeployments(t *testing.T) {
    13  	t.Parallel()
    14  
    15  	client := newIntegrationTestClient(t)
    16  
    17  	// Setup
    18  	appFilterName := "tf_" // Filter for integration test applications
    19  	appQueryParams := ListApplicationsParams{
    20  		Name: appFilterName,
    21  	}
    22  	applications, err := client.ListApplications(&appQueryParams)
    23  
    24  	if err != nil {
    25  		t.Skipf("Skipped Deployments integration test due error fetching applications: %s", err)
    26  		return
    27  	}
    28  
    29  	if len(applications) == 0 {
    30  		t.Skipf("Skipped Deployments integration test due to no applications being found for filter by name: %s", appFilterName)
    31  		return
    32  	}
    33  
    34  	application := applications[0]
    35  	newDeployment := Deployment{
    36  		Revision:    "master",
    37  		Changelog:   "v0.0.1",
    38  		Description: "testing",
    39  		User:        "foo",
    40  	}
    41  
    42  	// Test: Create
    43  	deployment, err := client.CreateDeployment(application.ID, newDeployment)
    44  
    45  	require.NoError(t, err)
    46  	require.NotNil(t, deployment)
    47  
    48  	// Test: List
    49  	listResult, err := client.ListDeployments(application.ID)
    50  
    51  	require.NoError(t, err)
    52  	require.Greater(t, len(listResult), 0)
    53  
    54  	// Test: Delete
    55  	result, err := client.DeleteDeployment(application.ID, deployment.ID)
    56  
    57  	require.NoError(t, err)
    58  	require.NotNil(t, result)
    59  }