testhelpers

package
v2.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPTimeout    = 60 * time.Second                                  // HTTPTimeout increases the timeout for integration tests
	LicenseKey     = "APMLicenseKey"                                   // LicenseKey used in mock configs
	LogLevel       = "debug"                                           // LogLevel used in mock configs
	PersonalAPIKey = "personalAPIKey"                                  // PersonalAPIKey used in mock configs (from Environment for Integration tests)
	UserAgent      = "newrelic/newrelic-client-go (automated testing)" // UserAgent used in mock configs
)
View Source
const IntegrationTestAccountID = 3806526

Our integration test account ID (v2 account)

View Source
const IntegrationTestApplicationEntityGUID = "MzgwNjUyNnxBUE18QVBQTElDQVRJT058NTczNDgyNjM4"

Our integration test Dummy App

View Source
const IntegrationTestApplicationEntityGUIDNew = "MzgwNjUyNnxBUE18QVBQTElDQVRJT058NTUzNDQ4MjAy"

Variables

This section is empty.

Functions

func GenerateRandomName added in v2.15.0

func GenerateRandomName(randCharCount int) string

Use this method to generate a random name to be used in integration tests for whatever resource you might be trying to create and/or test. If no random character count is provided, the default behavior is to append 5 random letters to the end of the name.

Example random name: nr-test-xmnvb

func GetNonExistentIDs added in v2.17.1

func GetNonExistentIDs() (string, string)

GetNonExistentIDs returns two non-existent IDs that can be used to test errors raised when Ingest/User keys which do not exist are updated or deleted.

func GetTestAccountID

func GetTestAccountID() (int, error)

GetTestAccountID returns the integer value for a New Relic Account ID from the environment

func GetTestUserID

func GetTestUserID() (int, error)

GetTestUserID returns the integer value for a New Relic user ID from the environment

func NewIntegrationTestConfig

func NewIntegrationTestConfig(t *testing.T) config.Config

NewIntegrationTestConfig grabs environment vars for required fields or skips the test. returns a fully saturated configuration

func NewMockServer

func NewMockServer(t *testing.T, mockJSONResponse string, statusCode int) *httptest.Server

NewMockServer creates a server to respond to API calls for unit tests

func NewTestConfig

func NewTestConfig(t *testing.T, testServer *httptest.Server) config.Config

NewTestConfig returns a fully saturated configration with modified BaseURLs for all endpoints based on the test server passed in

func RandSeq

func RandSeq(n int) string

RandSeq is used to get a string made up of n random lowercase letters.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL