Documentation ¶
Overview ¶
Package testutil is a generated GoMock package.
Index ¶
- Constants
- func AppFromContext(ctx context.Context) string
- func Assert(t Failable, m gomock.Matcher, actual interface{})
- func AssertContainsAll(t Failable, haystack string, needles []string)
- func AssertEqual(t Failable, fieldName string, expected, actual interface{})
- func AssertErrorContainsAll(t Failable, errorMsg error, expected []string)
- func AssertErrorsEqual(t Failable, expected, actual error)
- func AssertJSONEqual(t Failable, expected, actual string)
- func AssertKeyWithValue(t Failable, m map[interface{}]interface{}, key, value interface{})
- func AssertNil(t Failable, name string, value interface{})
- func AssertNotBlank(t Failable, name string, value string)
- func AssertNotNil(t Failable, name string, value interface{})
- func AssertRegexp(t Failable, fieldName, pattern, actual string)
- func BrokerFromContext(ctx context.Context) string
- func CancelOnSignal(ctx context.Context, cancel func(), log func(args ...interface{}))
- func CombineOutput(ctx context.Context, t *testing.T, out KfTestOutput) <-chan string
- func CombineOutputStr(ctx context.Context, t *testing.T, out KfTestOutput) []string
- func Compile(ctx context.Context, t *testing.T, codePath string) string
- func CompileKf(ctx context.Context, t *testing.T) string
- func ContextWithApp(ctx context.Context, appName string) context.Context
- func ContextWithBroker(ctx context.Context, brokerName string) context.Context
- func ContextWithServiceClass(ctx context.Context, serviceClassName string) context.Context
- func ContextWithServiceInstance(ctx context.Context, serviceInstanceName string) context.Context
- func ContextWithServicePlan(ctx context.Context, servicePlanName string) context.Context
- func ContextWithSpace(ctx context.Context, space string) context.Context
- func DockerRegistry() string
- func ExpectedAddr(hostname, urlPath string) string
- func Logf(t *testing.T, format string, i ...interface{})
- func PanicOnError(ctx context.Context, t *testing.T, messagePrefix string, errs <-chan error)
- func RetryGet(ctx context.Context, t *testing.T, addr string, duration time.Duration, ...) (*http.Response, func())
- func RetryOnPanic(ctx context.Context, t *testing.T, f func())
- func RetryPost(ctx context.Context, t *testing.T, addr string, duration time.Duration, ...) (*http.Response, func())
- func RootDir(ctx context.Context, t *testing.T) string
- func RunIntegrationTest(t *testing.T, test func(ctx context.Context, t *testing.T))
- func RunKfTest(t *testing.T, test KfTest)
- func ServiceClassFromContext(ctx context.Context) string
- func ServiceInstanceFromContext(ctx context.Context) string
- func ServicePlanFromContext(ctx context.Context) string
- func SpaceFromContext(ctx context.Context) string
- func StreamOutput(ctx context.Context, t *testing.T, out KfTestOutput)
- type AppInfo
- type Failable
- type FakeApiServer
- func (m *FakeApiServer) Create(arg0 schema.GroupVersionResource, arg1 string, arg2 runtime.Object) (runtime.Object, error)
- func (m *FakeApiServer) Delete(arg0 schema.GroupVersionResource, arg1, arg2 string) error
- func (m *FakeApiServer) EXPECT() *FakeApiServerMockRecorder
- func (m *FakeApiServer) Get(arg0 schema.GroupVersionResource, arg1, arg2 string) (runtime.Object, error)
- func (m *FakeApiServer) List(arg0 schema.GroupVersionResource, arg1 string, arg2 schema.GroupVersionKind, ...) (runtime.Object, error)
- func (m *FakeApiServer) Update(arg0 schema.GroupVersionResource, arg1 string, arg2 runtime.Object) (runtime.Object, error)
- type FakeApiServerMockRecorder
- func (mr *FakeApiServerMockRecorder) Create(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) Get(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) List(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- func (mr *FakeApiServerMockRecorder) Update(arg0, arg1, arg2 interface{}) *gomock.Call
- type Kf
- func (k *Kf) App(ctx context.Context, name string) json.RawMessage
- func (k *Kf) Apps(ctx context.Context) map[string]AppInfo
- func (k *Kf) BindService(ctx context.Context, appName string, serviceInstanceName string, ...)
- func (k *Kf) Bindings(ctx context.Context, extraArgs ...string) []string
- func (k *Kf) Buildpacks(ctx context.Context) []string
- func (k *Kf) CreateQuota(ctx context.Context, quotaName string, extraArgs ...string) ([]string, error)
- func (k *Kf) CreateRoute(ctx context.Context, domain string, extraArgs ...string)
- func (k *Kf) CreateService(ctx context.Context, serviceClass string, servicePlan string, ...)
- func (k *Kf) CreateServiceBroker(ctx context.Context, brokerName string, url string, extraArgs ...string)
- func (k *Kf) CreateSpace(ctx context.Context, space string) []string
- func (k *Kf) Delete(ctx context.Context, appName string, extraArgs ...string)
- func (k *Kf) DeleteQuota(ctx context.Context, quotaName string) ([]string, error)
- func (k *Kf) DeleteRoute(ctx context.Context, domain string, extraArgs ...string)
- func (k *Kf) DeleteService(ctx context.Context, serviceInstanceName string, extraArgs ...string)
- func (k *Kf) DeleteServiceBroker(ctx context.Context, brokerName string, extraArgs ...string)
- func (k *Kf) DeleteSpace(ctx context.Context, space string) []string
- func (k *Kf) Doctor(ctx context.Context)
- func (k *Kf) Env(ctx context.Context, appName string) map[string]string
- func (k *Kf) GetQuota(ctx context.Context, quotaName string) ([]string, error)
- func (k *Kf) Logs(ctx context.Context, appName string, extraArgs ...string) <-chan string
- func (k *Kf) MapRoute(ctx context.Context, appName, domain string, extraArgs ...string)
- func (k *Kf) Marketplace(ctx context.Context, extraArgs ...string) []string
- func (k *Kf) Proxy(ctx context.Context, appName string, port int)
- func (k *Kf) ProxyRoute(ctx context.Context, routeHost string, port int)
- func (k *Kf) Push(ctx context.Context, appName string, extraArgs ...string)
- func (k *Kf) Quotas(ctx context.Context) ([]string, error)
- func (k *Kf) Restart(ctx context.Context, appName string)
- func (k *Kf) Routes(ctx context.Context) []string
- func (k *Kf) RunSynchronous(ctx context.Context, cfg KfTestConfig) (stdout, stderr []byte, err error)
- func (k *Kf) Services(ctx context.Context, extraArgs ...string) []string
- func (k *Kf) SetEnv(ctx context.Context, appName, name, value string)
- func (k *Kf) Spaces(ctx context.Context) []string
- func (k *Kf) Stacks(ctx context.Context) []string
- func (k *Kf) Start(ctx context.Context, appName string)
- func (k *Kf) Stop(ctx context.Context, appName string)
- func (k *Kf) Target(ctx context.Context, namespace string) []string
- func (k *Kf) UnbindService(ctx context.Context, appName string, serviceInstanceName string, ...)
- func (k *Kf) UnmapRoute(ctx context.Context, appName, domain string, extraArgs ...string)
- func (k *Kf) UnsetEnv(ctx context.Context, appName, name string)
- func (k *Kf) UpdateQuota(ctx context.Context, quotaName string, extraArgs ...string) ([]string, error)
- func (k *Kf) VcapServices(ctx context.Context, extraArgs ...string) []string
- type KfTest
- type KfTestConfig
- type KfTestOutput
- type Reactable
- type TestApiServer
Constants ¶
const ( // EnvDockerRegistry is the environment variable used to store the // registry we will push containers to for the integration tests. If this // is not set, then the integration tests are skipped. EnvDockerRegistry = "DOCKER_REGISTRY" // IntegrationTestDomain is the domain that the integration test spaces // are setup with. IntegrationTestDomain = "integration-tests.kf.dev" )
Variables ¶
This section is empty.
Functions ¶
func AppFromContext ¶
AppFromContext returns the service plan name given a context that has been setup via ContextWithApp.
func AssertContainsAll ¶
AssertContainsAll validates that all of the search strings were in the main string. Case-insensitive.
func AssertEqual ¶
AssertEqual causes a test to fail if the two values are not DeepEqual to one another.
func AssertErrorContainsAll ¶
AssertErrorContainsAll checks that all of the search strings were in the error message. Case-insensitive.
func AssertErrorsEqual ¶
AssertErrorsEqual checks that the values of the two errors match.
func AssertJSONEqual ¶
AssertJSONEqual ensures the expexted JSON matches the actual JSON.
func AssertKeyWithValue ¶
func AssertKeyWithValue(t Failable, m map[interface{}]interface{}, key, value interface{})
AssertKeyWithValue ensures the key is present in the map and has the given value.
func AssertNotBlank ¶
AssertNotBlank is used to validate that strings are not just made of whitespace.
func AssertNotNil ¶
AssertNotNil fails the test if the value is nil.
func AssertRegexp ¶
AssertRegexp causes a test to fail if the value does not match a pattern.
func BrokerFromContext ¶
BrokerFromContext returns the broker name given a context that has been setup via ContextWithBroker.
func CancelOnSignal ¶
CancelOnSignal watches for a kill signal. If it gets one, it invokes the cancel function. An aditional signal will exit the process. If the given context finishes, the underlying go-routine finishes.
func CombineOutput ¶
CombineOutput writes the Stdout and Stderr to a channel for each line.
func CombineOutputStr ¶
CombineOutputStr writes the Stdout and Stderr string. It will return when ctx is done.
func Compile ¶
Compile compiles a path in the repo. It returns a path to the resulting binary. codePath must be relative to RootDir.
func ContextWithApp ¶
ContextWithApp returns a context that has the app information. The app name can be fetched via AppFromContext.
func ContextWithBroker ¶
ContextWithBroker returns a context that has the service broker information. The broker name can be fetched via BrokerFromContext.
func ContextWithServiceClass ¶
ContextWithServiceClass returns a context that has the service class information. The service class name can be fetched via ServiceClassFromContext.
func ContextWithServiceInstance ¶
ContextWithServiceInstance returns a context that has the service instance information. The service instance name can be fetched via ServiceInstanceFromContext.
func ContextWithServicePlan ¶
ContextWithServicePlan returns a context that has the service plan information. The service plan name can be fetched via ServiceInstanceFromContext.
func ContextWithSpace ¶
ContextWithSpace returns a context that has the space information. The space can be fetched via SpaceFromContext.
func DockerRegistry ¶
func DockerRegistry() string
DockerRegistry returns the configured docker registry for the integration tests.
func ExpectedAddr ¶
ExpectedAddr returns the expected address for integration tests given a hostname and URL path.
func Logf ¶
Logf will write to Stderr if testing.Verbose is true and t.Log otherwise. This is so logs will stream out instead of only being displayed at the end of the test.
func PanicOnError ¶
PanicOnError launches a go routine and waits for either the context or an error. An error will result in a panic. Why a panic in a test? t.Fatal is not thread safe. T.Failed() is thread safe, therefore we can use that to prevent the panic.
func RetryGet ¶ added in v0.2.0
func RetryGet( ctx context.Context, t *testing.T, addr string, duration time.Duration, expectedStatusCode int, ) (*http.Response, func())
RetryGet will send a get request until successful, duration has been reached or context is done. A close function is returned for closing the sub-context.
func RetryOnPanic ¶
RetryOnPanic will retry the function if it panics (e.g., via PanicOnError) until the given context is cancelled or the given function succeeds without panicking.
func RetryPost ¶
func RetryPost( ctx context.Context, t *testing.T, addr string, duration time.Duration, expectedStatusCode int, body string, ) (*http.Response, func())
RetryPost will post until successful, duration has been reached or context is done. A close function is returned for closing the sub-context.
func RootDir ¶
RootDir uses git to find the root of the directory. This is useful for tests (especially integration ones that compile things).
func RunIntegrationTest ¶
RunIntegrationTest skips the tests if testing.Short() is true (via --short flag) or if DOCKER_REGISTRY is not set. Otherwise it runs the given test.
func RunKfTest ¶
RunKfTest runs 'kf' for integration tests. It first compiles 'kf' and then launches it as a sub-process. It will set the args and environment variables accordingly. It will run the given test with the resulting STDOUT, STDERR and STDIN. It will cleanup the sub-process on completion via the context.
func ServiceClassFromContext ¶
ServiceClassFromContext returns the service class name given a context that has been setup via ContextWithServiceClass.
func ServiceInstanceFromContext ¶
ServiceInstanceFromContext returns the service instance name given a context that has been setup via ContextWithServiceInstance.
func ServicePlanFromContext ¶
ServicePlanFromContext returns the service plan name given a context that has been setup via ContextWithServicePlan.
func SpaceFromContext ¶
SpaceFromContext returns the space name given a context that has been setup via ContextWithSpace.
func StreamOutput ¶
func StreamOutput(ctx context.Context, t *testing.T, out KfTestOutput)
StreamOutput writes the output of KfTestOutput to the testing.Log if testing.Verbose is false and Stderr otherwise.
Types ¶
type AppInfo ¶
type AppInfo struct { Name string RequestedState string Instances string Memory string Disk string URLs []string }
AppInfo is the information returned by listing an app. It is returned by ListApp.
type Failable ¶
Failable is an interface for testing.T like things. We can't use testing.TB which would be preferable because they explicitly set a private field on it to prevent others from implementing it.
type FakeApiServer ¶
type FakeApiServer struct {
// contains filtered or unexported fields
}
FakeApiServer is a mock of TestApiServer interface
func AddFakeReactor ¶
func AddFakeReactor(fake Reactable, ctrl *gomock.Controller) *FakeApiServer
Adds a gomock compatible FakeApiServer to Kubernetes client-go testing.
func NewFakeApiServer ¶
func NewFakeApiServer(ctrl *gomock.Controller) *FakeApiServer
NewFakeApiServer creates a new mock instance
func (*FakeApiServer) Create ¶
func (m *FakeApiServer) Create(arg0 schema.GroupVersionResource, arg1 string, arg2 runtime.Object) (runtime.Object, error)
Create mocks base method
func (*FakeApiServer) Delete ¶
func (m *FakeApiServer) Delete(arg0 schema.GroupVersionResource, arg1, arg2 string) error
Delete mocks base method
func (*FakeApiServer) EXPECT ¶
func (m *FakeApiServer) EXPECT() *FakeApiServerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*FakeApiServer) Get ¶
func (m *FakeApiServer) Get(arg0 schema.GroupVersionResource, arg1, arg2 string) (runtime.Object, error)
Get mocks base method
func (*FakeApiServer) List ¶
func (m *FakeApiServer) List(arg0 schema.GroupVersionResource, arg1 string, arg2 schema.GroupVersionKind, arg3 labels.Selector) (runtime.Object, error)
List mocks base method
type FakeApiServerMockRecorder ¶
type FakeApiServerMockRecorder struct {
// contains filtered or unexported fields
}
FakeApiServerMockRecorder is the mock recorder for FakeApiServer
func (*FakeApiServerMockRecorder) Create ¶
func (mr *FakeApiServerMockRecorder) Create(arg0, arg1, arg2 interface{}) *gomock.Call
Create indicates an expected call of Create
func (*FakeApiServerMockRecorder) Delete ¶
func (mr *FakeApiServerMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call
Delete indicates an expected call of Delete
func (*FakeApiServerMockRecorder) Get ¶
func (mr *FakeApiServerMockRecorder) Get(arg0, arg1, arg2 interface{}) *gomock.Call
Get indicates an expected call of Get
func (*FakeApiServerMockRecorder) List ¶
func (mr *FakeApiServerMockRecorder) List(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
List indicates an expected call of List
func (*FakeApiServerMockRecorder) Update ¶
func (mr *FakeApiServerMockRecorder) Update(arg0, arg1, arg2 interface{}) *gomock.Call
Update indicates an expected call of Update
type Kf ¶
type Kf struct {
// contains filtered or unexported fields
}
Kf provides a DSL for running integration tests.
func (*Kf) BindService ¶
func (k *Kf) BindService(ctx context.Context, appName string, serviceInstanceName string, extraArgs ...string)
BindService runs the bind-service command.
func (*Kf) Buildpacks ¶
Buildpacks runs the buildpacks command.
func (*Kf) CreateQuota ¶
func (k *Kf) CreateQuota(ctx context.Context, quotaName string, extraArgs ...string) ([]string, error)
CreateQuota creates a resourcequota.
func (*Kf) CreateRoute ¶
CreateRoute runs the create-route command.
func (*Kf) CreateService ¶
func (k *Kf) CreateService(ctx context.Context, serviceClass string, servicePlan string, serviceInstanceName string, extraArgs ...string)
CreateService runs the create-service command.
func (*Kf) CreateServiceBroker ¶
func (k *Kf) CreateServiceBroker(ctx context.Context, brokerName string, url string, extraArgs ...string)
CreateServiceBroker runs the create-service-broker command.
func (*Kf) CreateSpace ¶
CreateSpace runs the create-space command.
func (*Kf) DeleteQuota ¶
DeleteQuota deletes a quota.
func (*Kf) DeleteRoute ¶
DeleteRoute runs the delete-route command.
func (*Kf) DeleteService ¶
DeleteService runs the delete-service command.
func (*Kf) DeleteServiceBroker ¶
DeleteServiceBroker runs the delete-service-broker command.
func (*Kf) DeleteSpace ¶
DeleteSpace runs the create-space command.
func (*Kf) Marketplace ¶
Marketplace runs the marketplace command and returns the output.
func (*Kf) ProxyRoute ¶ added in v0.2.0
ProxyRoute starts a proxy for a route.
func (*Kf) RunSynchronous ¶ added in v0.2.0
func (k *Kf) RunSynchronous(ctx context.Context, cfg KfTestConfig) (stdout, stderr []byte, err error)
RunSynchronous runs kf with the provided configuration and returns the results.
func (*Kf) UnbindService ¶
func (k *Kf) UnbindService(ctx context.Context, appName string, serviceInstanceName string, extraArgs ...string)
UnbindService runs the unbind-service command.
func (*Kf) UnmapRoute ¶ added in v0.2.0
UnmapRoute runs the unmap-route command.
type KfTestConfig ¶
KfTestConfig is a configuration for a Kf Test.
type KfTestOutput ¶
KfTestOutput is the output from `kf`. Note, this output is while kf is running.
type Reactable ¶
type Reactable interface {
AddReactor(verb, resource string, reaction testing.ReactionFunc)
}
type TestApiServer ¶
type TestApiServer interface { // Get retrieves the object by its kind, namespace and name. Get(gvr schema.GroupVersionResource, ns, name string) (runtime.Object, error) // Create adds an object in the specified namespace. Create(gvr schema.GroupVersionResource, ns string, obj runtime.Object) (runtime.Object, error) // Update updates an existing object in the specified namespace. Update(gvr schema.GroupVersionResource, ns string, obj runtime.Object) (runtime.Object, error) // List retrieves all objects of a given kind in the given namespace. List(gvr schema.GroupVersionResource, ns string, gvk schema.GroupVersionKind, labelSelector labels.Selector) (runtime.Object, error) // Delete deletes an existing object. Delete(gvr schema.GroupVersionResource, ns, name string) error }