github.com/newrelic/newrelic-client-go@v1.1.0/pkg/logs/logs_integration_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  // Requires NEW_RELIC_LICENSE_KEY envvar (APM License Key)
     5  
     6  package logs
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/stretchr/testify/assert"
    12  
    13  	nr "github.com/newrelic/newrelic-client-go/pkg/testhelpers"
    14  )
    15  
    16  type testDatum struct {
    17  	Datum interface{}
    18  	err   error
    19  }
    20  
    21  var testData = []testDatum{
    22  	{
    23  		Datum: struct {
    24  			Message string `json:"message"`
    25  		}{
    26  			Message: "INFO: simple message test",
    27  		},
    28  		err: nil,
    29  	},
    30  }
    31  
    32  func TestIntegrationLogs(t *testing.T) {
    33  	t.Parallel()
    34  
    35  	client := newIntegrationTestClient(t)
    36  
    37  	for _, test := range testData {
    38  		err := client.CreateLogEntry(test.Datum)
    39  		if test.err == nil {
    40  			assert.NoError(t, err)
    41  		} else {
    42  			assert.Equal(t, test.err, err)
    43  		}
    44  	}
    45  }
    46  
    47  func newIntegrationTestClient(t *testing.T) Logs {
    48  	tc := nr.NewIntegrationTestConfig(t)
    49  
    50  	return New(tc)
    51  }