test

package
v1.111.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const Namespace = "namespace-1"

Variables

This section is empty.

Functions

func AddTestLabelsToMap

func AddTestLabelsToMap(m map[string]string)

AddTestLabelsToMap adds test labels to a map directly.

func CRDForGVK added in v1.95.0

func EnsureObjectExists

func EnsureObjectExists(t *testing.T, obj *unstructured.Unstructured, c client.Client)

func EnsureObjectsExist

func EnsureObjectsExist(t *testing.T, objs []*unstructured.Unstructured, c client.Client)

func Equals

func Equals(t *testing.T, o1, o2 interface{}) bool

func FakeCRDsWithHierarchicalResources

func FakeCRDsWithHierarchicalResources() []*apiextensions.CustomResourceDefinition

FakeCRDsWithHierarchicalResources returns a CRD list which includes hierarchical resources to allow for the testing of resources that reference hierarchical resources (e.g. "Project")

func FakeServiceMappings

func FakeServiceMappings() []v1alpha1.ServiceMapping

func FakeServiceMappingsWithHierarchicalResources

func FakeServiceMappingsWithHierarchicalResources() []v1alpha1.ServiceMapping

FakeServiceMappingsWithHierarchicalResources returns a ServiceMapping list which includes hierarchical resources to allow for the testing of resources that reference hierarchical resources (e.g. "Project")

func NewBarUnstructured

func NewBarUnstructured(name, ns string, readyStatus corev1.ConditionStatus) *unstructured.Unstructured

func NewFolderUnstructured

func NewFolderUnstructured(name, folderID string, readyStatus corev1.ConditionStatus) *unstructured.Unstructured

func NewIAMServiceAccountUnstructured

func NewIAMServiceAccountUnstructured(name, namespace string) *unstructured.Unstructured

func NewProjectUnstructured

func NewProjectUnstructured(name, projectID string, readyStatus corev1.ConditionStatus) *unstructured.Unstructured

func NewSecretUnstructured

func NewSecretUnstructured(name, ns string, stringData map[string]interface{}) *unstructured.Unstructured

func StringMatchesRegexList

func StringMatchesRegexList(t *testing.T, regexesToMatch []string, targetString string) bool

StringMatchesRegexList is a test utility that returns true if the string matches any regex in a list of strings.

if a regex fails to compile, the test will fail.

func TestFromContext added in v1.96.0

func TestFromContext(ctx context.Context) *testing.T

func ToUnstruct

func ToUnstruct(t *testing.T, bytes []byte) *unstructured.Unstructured

func ToUnstructWithNamespace

func ToUnstructWithNamespace(t *testing.T, b []byte, namespace string) *unstructured.Unstructured

func TrimLicenseHeaderFromTF

func TrimLicenseHeaderFromTF(yaml string) string

TrimLicenseHeaderFromTF trims the license header in the tf string.

func TrimLicenseHeaderFromYaml

func TrimLicenseHeaderFromYaml(yaml string) string

TrimLicenseHeaderFromYaml trims the license header in the yaml string.

func WithContext added in v1.96.0

func WithContext(ctx context.Context, t *testing.T) context.Context

Types

type HTTPRecorder added in v1.96.0

type HTTPRecorder struct {
	// contains filtered or unexported fields
}

func NewHTTPRecorder added in v1.96.0

func NewHTTPRecorder(inner http.RoundTripper, outputDir string) *HTTPRecorder

func (*HTTPRecorder) RoundTrip added in v1.96.0

func (r *HTTPRecorder) RoundTrip(req *http.Request) (*http.Response, error)

type LogEntry added in v1.96.0

type LogEntry struct {
	Timestamp time.Time `json:"timestamp,omitempty"`
	Request   Request   `json:"request,omitempty"`
	Response  Response  `json:"response,omitempty"`
	Error     string    `json:"error,omitempty"`
}

type Request added in v1.96.0

type Request struct {
	Method string      `json:"method,omitempty"`
	URL    string      `json:"url,omitempty"`
	Header http.Header `json:"header,omitempty"`
	Body   string      `json:"body,omitempty"`
}

type Response added in v1.96.0

type Response struct {
	Status     string      `json:"status,omitempty"`
	StatusCode int         `json:"statusCode,omitempty"`
	Header     http.Header `json:"header,omitempty"`
	Body       string      `json:"body,omitempty"`
}

type TestType

type TestType string
const (
	UnitTestType        TestType = "Unit"
	IntegrationTestType TestType = "Integration"
)

Directories

Path Synopsis
testsconstants contains constants used in tests.
testsconstants contains constants used in tests.

Jump to

Keyboard shortcuts

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