testutil

package
v0.6.3-0...-140fefd Latest Latest
Warning

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

Go to latest
Published: May 4, 2017 License: Apache-2.0 Imports: 17 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 EqualNormalizedString

func EqualNormalizedString(t require.TestingT, transformFun func(rune) rune, actual, expected string)

EqualNormalizedString compare the actual value to the expected value after applying the specified transform function. It fails the test if these two transformed string are not equal. For example `EqualNormalizedString(t, RemoveSpace, "foo\n", "foo")` wouldn't fail the test as spaces (and thus '\n') are removed before comparing the string.

func ErrorContains

func ErrorContains(t require.TestingT, err error, expectedError string)

ErrorContains checks that the error is not nil, and contains the expected substring.

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 RemoveSpace

func RemoveSpace(r rune) rune

RemoveSpace returns -1 if the specified runes is considered as a space (unicode) and the rune itself otherwise.

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 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