testutils

package
v0.0.0-...-94a580d Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

package testutils holds a collection of utility functions to help with testing go packages ─── ACKNOWLEDGEMENTS ───────────────────────────────────────────────────────────

────────────────────────────────────────────────────────────────────────────────

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcurrentCases

func ConcurrentCases() []int

ConcurrentCases returns an array of integer which is used for number of cores when running concurrent benchmarks

func NewDeleteRequest

func NewDeleteRequest(endpoint string) (*http.Request, *httptest.ResponseRecorder)

NewDeleteRequest ...

func NewGetRequest

func NewGetRequest(endpoint string) (*http.Request, *httptest.ResponseRecorder)

NewGetRequest ...

func NewPostRequestWithBody

func NewPostRequestWithBody(endpoint string, body interface{}) (*http.Request, *httptest.ResponseRecorder)

NewPostRequestWithBody ...

func NewRandomReader

func NewRandomReader(blockSize int) io.Reader

NewRandomReader - make a new random stream generator random reader is used to generate random streams of bytes used for testing io operations https://github.com/ncw/stressdisk

func RandomJSON

func RandomJSON() bytes.Buffer

[ TODO ] => implement

func RandomMap

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

RandomMap uses json codec to return a randomized map

func RandomProperties

func RandomProperties() bytes.Buffer

[ TODO ] => implement

func RandomYaml

func RandomYaml() bytes.Buffer

func TempDir

func TempDir(t testing.TB, name string) string

func TempFile

func TempFile(t testing.TB, name string) *os.File

func Wait

func Wait(timeout time.Duration, f CheckFunc) error

Types

type CapturedStacktrace

type CapturedStacktrace string

CapturedStacktrace ...

func Stacktrace

func Stacktrace() CapturedStacktrace

Stacktrace - captures a stacktrace of the current goroutine github.com/hashicorp/go-hclog

type CheckFunc

type CheckFunc func() (bool, error)

type RWTestCase

type RWTestCase struct {
	Size                     int
	Unit                     int
	Expect                   []byte
	CustomWriteTester        func(t *testing.T, w Writer)
	CustomWriteToTester      func(t *testing.T, w WriterTo)
	CustomReaderWriterTester func(t *testing.T, r ReaderWriter)
}

RWTestCase define test cases used in testing Write([]byte) and Read([]byte) for unit , use values in primitives package

func GenerateRWTests

func GenerateRWTests() []RWTestCase

GenerateRWTests generates test for to help with testing io.writer and readers

type Reader

type Reader interface {
	Read(p []byte) (n int, err error)
	Len() int
}

Reader ...

type ReaderWriter

type ReaderWriter interface {
	Writer
	Read(p []byte) (n int, err error)
}

ReaderWriter ...

type Writer

type Writer interface {
	Write(p []byte) (int, error)
	Bytes() []byte
	Len() int
	Reset()
}

Writer ...

type WriterTo

type WriterTo interface {
	Writer
	WriteTo(w io.Writer) (int64, error)
}

WriterTo ...

Jump to

Keyboard shortcuts

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