testutil

package
v0.1.3-0...-f63d1a6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareDirectoryEntries

func CompareDirectoryEntries(e1 []os.FileInfo, e2 []os.FileInfo) error

CompareDirectoryEntries compares two sets of FileInfo (usually taken from a directory) and returns an error if different.

func ConsumeWithSpeed

func ConsumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error)

ConsumeWithSpeed reads chunkSize bytes from reader before sleeping for interval duration. Returns total read bytes. Send true to the stop channel to return before reading to EOF on the reader.

func ConvertSliceOfStringsToMap

func ConvertSliceOfStringsToMap(input []string) map[string]struct{}

ConvertSliceOfStringsToMap converts a slices of string in a map with the strings as key and an empty string as values.

func IsKilled

func IsKilled(err error) bool

IsKilled process the specified error and returns whether the process was killed or not.

func ListTar

func ListTar(f io.Reader) ([]string, error)

ListTar lists the entries of a tar.

func ParseCgroupPaths

func ParseCgroupPaths(procCgroupData string) map[string]string

ParseCgroupPaths parses 'procCgroupData', which is output of '/proc/<pid>/cgroup', and returns a map which cgroup name as key and path as value.

func RandomTmpDirPath

func RandomTmpDirPath(s string, platform string) string

RandomTmpDirPath provides a temporary path with rand string appended. does not create or checks if it exists.

func ReadBody

func ReadBody(b io.ReadCloser) ([]byte, error)

ReadBody read the specified ReadCloser content and returns it

func RunAtDifferentDate

func RunAtDifferentDate(date time.Time, block func())

RunAtDifferentDate runs the specified function with the given time. It changes the date of the system, which can led to weird behaviors.

func RunCommandPipelineWithOutput

func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, exitCode int, err error)

RunCommandPipelineWithOutput runs the array of commands with the output of each pipelined with the following (like cmd1 | cmd2 | cmd3 would do). It returns the final output, the exitCode different from 0 and the error if something bad happened.

Types

type ChannelBuffer

type ChannelBuffer struct {
	C chan []byte
}

ChannelBuffer holds a chan of byte array that can be populate in a goroutine.

func (*ChannelBuffer) Close

func (c *ChannelBuffer) Close() error

Close closes the go channel.

func (*ChannelBuffer) ReadTimeout

func (c *ChannelBuffer) ReadTimeout(p []byte, n time.Duration) (int, error)

ReadTimeout reads the content of the channel in the specified byte array with the specified duration as timeout.

func (*ChannelBuffer) Write

func (c *ChannelBuffer) Write(b []byte) (int, error)

Write implements Writer.

Directories

Path Synopsis
Package assert contains functions for making assertions in unit tests
Package assert contains functions for making assertions in unit tests
Package golden provides function and helpers to use golden file for testing purpose.
Package golden provides function and helpers to use golden file for testing purpose.

Jump to

Keyboard shortcuts

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