testing

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2018 License: Apache-2.0 Imports: 15 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NullRecorder = &nullRecorder{}

NullRecorder ignores all the items passed to it via Rec.

Functions

func DirToMap

func DirToMap(dir string) (map[string]interface{}, error)

DirToMap converts directory to a map where keys are filenames without full path and values are the contents of the files. Files with '.iso' extensions are unpacked using 7z and then converted to a map using DirToMap. Directories are handled recursively. If the directory doesn't exist, dirToMap returns nil

func EncodePEMCert added in v0.9.4

func EncodePEMCert(cert *x509.Certificate) string

func EncodePEMKey added in v0.9.4

func EncodePEMKey(key *rsa.PrivateKey) string

func GenerateCert added in v0.9.4

func GenerateCert(t *testing.T, isCA bool, host string, signer *x509.Certificate, key *rsa.PrivateKey) (*x509.Certificate, *rsa.PrivateKey)

func IsoToMap

func IsoToMap(isoPath string) (map[string]interface{}, error)

IsoToMap converts an iso image to a map where keys are filenames without full path and values are the contents of the files. It does so by unpacking the image into a temporary directory and processing it with DirToMap.

Types

type ChildRecorder added in v1.0.2

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

ChildRecorder is a recorder that prefixes the names of its items with the specified prefix and then passes them to its parent recorder.

func NewChildRecorder added in v1.0.2

func NewChildRecorder(parent Recorder, prefix string) *ChildRecorder

NewChildRecorder creates a new ChildRecorder.

func (*ChildRecorder) Child added in v1.0.2

func (r *ChildRecorder) Child(prefix string) *ChildRecorder

Child creates a Child recorder for this recorder.

func (*ChildRecorder) Rec added in v1.0.2

func (r *ChildRecorder) Rec(name string, data interface{})

Rec implements Rec method of Recorder interface.

type Record added in v1.0.2

type Record struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value,omitempty"`
}

Record denotes an item saved by Recorder's Rec method.

type Recorder added in v1.0.2

type Recorder interface {
	// Rec adds an item to Recorder using the specified name and data.
	Rec(name string, data interface{})
}

Recorder is used to record various events for use in tests.

type TestCommand added in v0.9.4

type TestCommand struct {
	Command *exec.Cmd
	// contains filtered or unexported fields
}

func RunProcess added in v0.9.4

func RunProcess(t *testing.T, command string, args []string, env []string) *TestCommand

RunProcess runs a background process with specified args and appending env to the current environment.

func (*TestCommand) Pid added in v0.9.4

func (tc *TestCommand) Pid() int

func (*TestCommand) Stop added in v0.9.4

func (tc *TestCommand) Stop()

type TopLevelRecorder added in v1.0.2

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

TopLevelRecorder records the items as-is, optionally applying filters to them. It can also create child recorders and give back its current contents.

func NewToplevelRecorder added in v1.0.2

func NewToplevelRecorder() *TopLevelRecorder

NewToplevelRecorder creates a new TopLevelRecorder.

func (*TopLevelRecorder) AddFilter added in v1.0.2

func (r *TopLevelRecorder) AddFilter(filter string)

AddFilter adds a new filter substring to the TopLevelRecorder. If any filter substrings are specified, Rec will ignore items with names that don't include any of these substrings (i.e. the filters are ORed)

func (*TopLevelRecorder) Child added in v1.0.2

func (r *TopLevelRecorder) Child(prefix string) *ChildRecorder

Child creates a Child recorder for this TopLevelRecorder that will add the specified prefix (plus ": ") to the names of items it records.

func (*TopLevelRecorder) Content added in v1.0.2

func (r *TopLevelRecorder) Content() []*Record

Content returns the current contents of the recorder.

func (*TopLevelRecorder) Rec added in v1.0.2

func (r *TopLevelRecorder) Rec(name string, value interface{})

Rec implements Rec method of Recorder interface.

Jump to

Keyboard shortcuts

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