test

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSecret

func CreateSecret(key string, opts ...SecretOptFunc) *corev1.Secret

CreateSecret creates and returns a new Secret with the provided key in the data.

A slice of SecretOptFuncs can be used to modify the returned secret.

func MakeHookFromFixture

func MakeHookFromFixture(t *testing.T, filename, eventType string) scm.Webhook

MakeHookFromFixture creates and returns a WebHook parsed from the provided fixture file, with the correct X-GitHub-Event type etc.

func MakeHookRequest

func MakeHookRequest(t *testing.T, fixture, eventType string, changes ...fixtureFunc) *http.Request

MakeHookRequest creates and returns a new http.Request that resembles a GitHub hook request, including the correct event type and reading and sending a fixture as a JSON body.

Optionally changes can be applied to the fixture that is read, before it's sent. TODO use uuid to generate the Delivery ID.

func MatchError

func MatchError(t *testing.T, s string, e error) bool

MatchError checks errors against a regexp.

Returns true if the string is empty and the error is nil. Returns false if the string is not empty and the error is nil. Otherwise returns the result of a regexp match against the string.

func ReadJSONFixture

func ReadJSONFixture(t *testing.T, filename string) map[string]interface{}

ReadJSONFixture reads a filename into a map, and fails the test if it is unable to open or parse the file.

func UnmarshalJSON

func UnmarshalJSON(t *testing.T, b []byte) map[string]interface{}

UnmarshalJSON unmarshals a byte-slice to a map.

Types

type SecretOptFunc

type SecretOptFunc func(*corev1.Secret)

Jump to

Keyboard shortcuts

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