testing

package
v0.0.0-...-feae1d6 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2014 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package testing provides a fake implementation of the Docker API, useful for testing purpose.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerServer

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

DockerServer represents a programmable, concurrent (not much), HTTP server implementing a fake version of the Docker remote API.

It can used in standalone mode, listening for connections or as an arbitrary HTTP handler.

For more details on the remote API, check http://goo.gl/yMI1S.

func NewServer

func NewServer(bind string, hook func(*http.Request)) (*DockerServer, error)

NewServer returns a new instance of the fake server, in standalone mode. Use the method URL to get the URL of the server.

It receives the bind address (use 127.0.0.1:0 for getting an available port on the host) and a hook function, that will be called on every request.

func (*DockerServer) PrepareFailure

func (s *DockerServer) PrepareFailure(id string, spec FailureSpec)

PrepareFailure adds a new expected failure based on a FailureSpec it receives an id for the failure and the spec.

func (*DockerServer) ResetFailure

func (s *DockerServer) ResetFailure(id string)

ResetFailure removes an expected failure identified by the id

func (*DockerServer) ServeHTTP

func (s *DockerServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP requests sent to the server.

func (*DockerServer) Stop

func (s *DockerServer) Stop()

Stop stops the server.

func (*DockerServer) URL

func (s *DockerServer) URL() string

URL returns the HTTP URL of the server.

type FailureSpec

type FailureSpec struct {
	UrlRegex      string
	ContainerPath string
	ContainerArgs []string
}

FailureSpec is used with PrepareFailure and describes in which situations the request should fail. UrlRegex is mandatory, if a container id is sent on the request you can also specify the other properties.

Jump to

Keyboard shortcuts

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