Documentation ¶
Index ¶
- func APICallWithRetry(t *testing.T, attempts int, sleep time.Duration, callback func() error) (err error)
- func APIClient() *client.Fn
- func AnnotationsEquivalent(md1, md2 map[string]interface{}) bool
- func AssertRouteMatches(t *testing.T, expected *models.Route, got *models.Route)
- func CallFN(u string, content io.Reader, output io.Writer, method string, env []string) (http.Header, error)
- func ConfigEquivalent(a map[string]string, b map[string]string) bool
- func EnvAsHeader(req *http.Request, selectedEnv []string)
- func GetAPIURL() (string, *url.URL)
- func Host() string
- func RandStringBytes(n int) string
- type TestHarness
- func (s *TestHarness) AppMustExist(t *testing.T, appName string) *models.App
- func (s *TestHarness) BasicRoute() *models.Route
- func (s *TestHarness) Cleanup()
- func (s *TestHarness) GivenAppExists(t *testing.T, app *models.App)
- func (s *TestHarness) GivenRouteExists(t *testing.T, appName string, route *models.Route)
- func (s *TestHarness) GivenRoutePatched(t *testing.T, appName, routeName string, rt *models.Route)
- func (s *TestHarness) PostApp(app *models.App) (*apps.PostAppsOK, error)
- func (s *TestHarness) PostRoute(appName string, route *models.Route) (*routes.PostAppsAppRoutesOK, error)
- func (s *TestHarness) PutRoute(appName string, routePath string, route *models.Route) (*routes.PutAppsAppRoutesRouteOK, error)
- func (s *TestHarness) RouteMustExist(t *testing.T, appName string, routePath string) *models.Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APICallWithRetry ¶
func AnnotationsEquivalent ¶
AnnotationsEquivalent checks if two annotations maps are semantically equivalent, including nil == empty map
func AssertRouteMatches ¶
func ConfigEquivalent ¶
ConfigEquivalent checks if two config objects are semantically equivalent (including nils)
func EnvAsHeader ¶
func RandStringBytes ¶
Types ¶
type TestHarness ¶
type TestHarness struct { Context context.Context Cancel func() Client *client.Fn AppName string RoutePath string Image string RouteType string Format string Memory uint64 Timeout int32 IdleTimeout int32 RouteConfig map[string]string RouteHeaders map[string][]string // contains filtered or unexported fields }
TestHarness provides context and pre-configured clients to an individual test, it has some helper functions to create Apps and Routes that mirror the underlying client operations and clean them up after the test is complete This is not goroutine safe and each test case should use its own harness.
func SetupHarness ¶
func SetupHarness() *TestHarness
SetupHarness creates a test harness for a test case - this picks up external options and
func (*TestHarness) AppMustExist ¶
AppMustExist fails the test if the specified app does not exist
func (*TestHarness) BasicRoute ¶
func (s *TestHarness) BasicRoute() *models.Route
func (*TestHarness) Cleanup ¶
func (s *TestHarness) Cleanup()
func (*TestHarness) GivenAppExists ¶
func (s *TestHarness) GivenAppExists(t *testing.T, app *models.App)
GivenAppExists creates an app and ensures it is deleted on teardown, this fatals if the app is not created
func (*TestHarness) GivenRouteExists ¶
GivenRouteExists creates a route using the specified arguments, failing the test if the creation fails, this tears down any apps that are created when the test is complete
func (*TestHarness) GivenRoutePatched ¶
GivenRoutePatched applies a patch to a route, failing the test if this fails.
func (*TestHarness) PostApp ¶
func (s *TestHarness) PostApp(app *models.App) (*apps.PostAppsOK, error)
PostApp creates an app and esures it is deleted on teardown if it was created
func (*TestHarness) PostRoute ¶
func (s *TestHarness) PostRoute(appName string, route *models.Route) (*routes.PostAppsAppRoutesOK, error)
PostRoute Creates a route and deletes the corresponding app (if created) on teardown
func (*TestHarness) PutRoute ¶
func (s *TestHarness) PutRoute(appName string, routePath string, route *models.Route) (*routes.PutAppsAppRoutesRouteOK, error)
PutRoute creates a route via PUT, tearing down any apps that are created when the test is complete
func (*TestHarness) RouteMustExist ¶
RouteMustExist checks that a route exists, failing the test if it doesn't, returns the route