Documentation ¶
Overview ¶
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0 Package testhelpers provide some helper functions that are useful for testing
Index ¶
- Variables
- func Eventually(t *testing.T, timeout time.Duration, testFunc func(_ require.TestingT))
- func GetFreePort() (int, error)
- func GetFreeTCPPort() (port int, err error)
- func InventoryDuration(pluginIntervalSecs int64) time.Duration
- func NewFakeHostnameResolver(full, short string, err error) hostname.ResolverChangeNotifier
- func NewMockDir(files []MockFile) (mockDir, error)
- func PopulateDeltas(dataDir string, entityKey string, deltasInfos []FakeDeltaEntry)
- func Setenv(variable, value string) func()
- func SetupLog()
- type FakeDeltaEntry
- type MockFile
- type PostDeltaTracer
Constants ¶
This section is empty.
Variables ¶
var NullHostnameResolver = &fakeHostnameResolver{}
Functions ¶
func Eventually ¶
Eventually retries a test until it eventually succeeds. If the timeout is reached, the test fails with the same failure as its last execution.
func GetFreePort ¶
GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreeTCPPort ¶
GetFreeTCPPort returns a free open TCP port
func InventoryDuration ¶
func NewFakeHostnameResolver ¶
func NewFakeHostnameResolver(full, short string, err error) hostname.ResolverChangeNotifier
func NewMockDir ¶
NewMockDir mocks a system directory and creates the given `MockFile` inside the new temp directory.
func PopulateDeltas ¶
func PopulateDeltas(dataDir string, entityKey string, deltasInfos []FakeDeltaEntry)
PopulateDeltas creates a set of synthetic, fake deltas for a given entity, in the given data directory. The deltas will be inserted in the dataDir/.delta_repo folder.
Types ¶
type FakeDeltaEntry ¶
type FakeDeltaEntry struct { // Source is the categorized name of the plugin, e.g. 'packages/rpm' Source string // DeltasSize is the approximate size of all the unsent deltas for this plugin DeltasSize int // BodySize is the approximate size of the inventory JSON body for this plugin BodySize int }
FakeDeltaEntry provides meta information about a plugin deltas set
type PostDeltaTracer ¶
type PostDeltaTracer struct { Sources []map[string]interface{} Errors []error PostDeltas func(_ []string, _ entity.ID, _ bool, _ ...*inventoryapi.RawDelta) (*inventoryapi.PostDeltaResponse, error) PostDeltasVortex func(_ entity.ID, _ []string, _ bool, _ ...*inventoryapi.RawDelta) (*inventoryapi.PostDeltaResponse, error) }
PostDeltaTracer traces metadata about invocations to a fake inventory ingest service
func NewPostDeltaTracer ¶
func NewPostDeltaTracer(maxDeltaSize int) *PostDeltaTracer
NewPostDeltaTracer creates a PostDeltaTracer whose PostDeltas method returns an error if the total submitted deltas are larger than the maxDeltaSize parameter.