testutil

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package testutil provides common helper for tests.

Index

Constants

View Source
const (
	// KubeconfigEnv is a environment variable name which points to kubeconfig file which will be used for testing.
	KubeconfigEnv = "KUBECONFIG"
)

Variables

This section is empty.

Functions

func CheckStatusCodeOK

func CheckStatusCodeOK(ctx context.Context, t *testing.T, httpClient *http.Client, url string) []byte

CheckStatusCodeOK calls RetryGetRequestAndCheckStatus with a failCondition function checking for any response not equal to 200.

func ContextWithDeadline

func ContextWithDeadline(t *testing.T) context.Context

ContextWithDeadline returns context with will timeout before t.Deadline().

func RetryGetRequestAndCheckStatus added in v0.3.0

func RetryGetRequestAndCheckStatus(
	ctx context.Context, t *testing.T, httpClient *http.Client, url string, failCondition func(statusCode int) bool,
) []byte

RetryGetRequestAndCheckStatus sends GET request to given URL.

If 401 or 403 return code is received, function will retry.

If other return code is received, function will check the failCondition to fail the given test.

Types

type TestEnv

type TestEnv struct {
	PersonalAPIKey  string
	AccountID       string
	Region          string
	Config          string
	ConfigPath      string
	ServingCertPath string
	ServingKeyPath  string
	KubeconfigPath  string
	Port            string
	Host            string
	BaseURL         string
	Flags           []string
	ContextTimeout  time.Duration
	StartKubernetes bool
	Context         context.Context
	RestConfig      *rest.Config
	HTTPClient      *http.Client
}

TestEnv is a helper struct for accessing data required for integration and e2e tests like API key and to perform common test tasks, like generating clients, parameters for adapter etc.

func (*TestEnv) Generate

func (te *TestEnv) Generate(t *testing.T)

Generate fills empty TestEnv struct fields with values.

Jump to

Keyboard shortcuts

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