stream

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer func(w *os.File)

Consumer is a function that consumes a file

type Expectations added in v0.0.3

type Expectations interface {
	// Close frees up resources
	Close() error

	// Size returns an Expectation about the size of the data in bytes
	Size() expect.Expectation

	// Text returns an Expectation about the data as utf-8 text
	Text() expect.Expectation
	// NextText returns an Expectation about the next chunk of text
	NextText(bytes int) expect.Expectation
	// TextAt returns an Expectation about text starting at the given byte offset
	TextAt(pos int64, bytes int) expect.Expectation

	// Bytes returns an Expectation about the data as a byte array
	Bytes() expect.Expectation
	// NextBytes returns an Expectation about the next chunk of bytes
	NextBytes(bytes int) expect.Expectation
	// BytesAt returns an Expectation about the bytes starting at the given offset
	BytesAt(pos int64, bytes int) expect.Expectation

	// Lines returns an Expectation about the data as lines of text
	Lines() expect.Expectation
	// NextLine returns an Expectation about the next line of text
	NextLine() expect.Expectation

	// ContentType returns an Expectation about the media type.
	// See https://en.wikipedia.org/wiki/Media_type
	ContentType() expect.Expectation
}

Expectations is a set of expectations about a data stream

func ExpectFile added in v0.0.3

func ExpectFile(t *testing.T, file *os.File) Expectations

ExpectFile returns expectations based on a file descriptor

func ExpectWritten added in v0.0.3

func ExpectWritten(t *testing.T, consumer Consumer) Expectations

ExpectWritten returns expectations based on a function that writes to a stream

func Faulty

func Faulty(t *testing.T, err error) Expectations

Faulty returns a new Fault

type Fault

type Fault struct {
	*testing.T
	// contains filtered or unexported fields
}

Fault is a set of stream expectations that always result in an error

func (*Fault) Bytes

func (f *Fault) Bytes() expect.Expectation

Bytes returns a faulty Expectation

func (*Fault) BytesAt

func (f *Fault) BytesAt(pos int64, bytes int) expect.Expectation

BytesAt returns a faulty Expectation

func (*Fault) Close

func (f *Fault) Close() error

Close returns no error

func (*Fault) ContentType

func (f *Fault) ContentType() expect.Expectation

ContentType returns a faulty Expectation

func (*Fault) Lines added in v0.0.2

func (f *Fault) Lines() expect.Expectation

Lines returns a faulty Expectation

func (*Fault) NextBytes

func (f *Fault) NextBytes(bytes int) expect.Expectation

NextBytes returns a faulty Expectation

func (*Fault) NextLine added in v0.0.2

func (f *Fault) NextLine() expect.Expectation

NextLine returns a faulty Expectation

func (*Fault) NextText

func (f *Fault) NextText(bytes int) expect.Expectation

NextText returns a faulty Expectation

func (*Fault) Size

func (f *Fault) Size() expect.Expectation

Size returns a faulty Expectation

func (*Fault) Text

func (f *Fault) Text() expect.Expectation

Text returns a faulty Expectation

func (*Fault) TextAt

func (f *Fault) TextAt(pos int64, bytes int) expect.Expectation

TextAt returns a faulty Expectation

type File

type File struct {
	*testing.T
	// contains filtered or unexported fields
}

File is a set of expectations about a file stream

func (*File) Bytes

func (f *File) Bytes() expect.Expectation

Bytes returns an Expectation about the entire file contents

func (*File) BytesAt

func (f *File) BytesAt(pos int64, bytes int) expect.Expectation

BytesAt returns an Expectation about the file contents at a specific position

func (*File) Close

func (f *File) Close() error

Close the underlying file descriptor

func (*File) ContentType

func (f *File) ContentType() expect.Expectation

ContentType returns an Expectation about the content type

func (*File) Lines added in v0.0.2

func (f *File) Lines() expect.Expectation

Lines returns an Expectation about the entire file contents as lines of text

func (*File) NextBytes

func (f *File) NextBytes(bytes int) expect.Expectation

NextBytes returns an Expectation about the next chunk of bytes

func (*File) NextLine added in v0.0.2

func (f *File) NextLine() expect.Expectation

NextLine returns an Expectation about the next line of text

func (*File) NextText

func (f *File) NextText(bytes int) expect.Expectation

NextText returns an Expectation about the next chunk of text

func (*File) Size

func (f *File) Size() expect.Expectation

Size returns an Expectation about the file size in bytes

func (*File) Text

func (f *File) Text() expect.Expectation

Text returns an Expectation about the entire file contents as text

func (*File) TextAt

func (f *File) TextAt(pos int64, bytes int) expect.Expectation

TextAt returns an Expectation about the text contents at a specific position

type Writable

type Writable struct {
	*testing.T
	// contains filtered or unexported fields
}

Writable is a set of expectations about a writable stream

func (*Writable) Bytes

func (w *Writable) Bytes() expect.Expectation

Bytes returns an Expectation about all bytes written to the stream

func (*Writable) BytesAt

func (w *Writable) BytesAt(pos int64, bytes int) expect.Expectation

BytesAt returns an Expectation about the bytes written at a specific position

func (*Writable) Close

func (w *Writable) Close() error

Close the stream and remove the temporary file

func (*Writable) ContentType

func (w *Writable) ContentType() expect.Expectation

ContentType returns an Expectation about content type written to the stream

func (*Writable) Lines added in v0.0.2

func (w *Writable) Lines() expect.Expectation

Lines returns an Expectation about all lines of text written to the stream

func (*Writable) NextBytes

func (w *Writable) NextBytes(bytes int) expect.Expectation

NextBytes returns an Expectation about the next chunk of bytes written to the stream

func (*Writable) NextLine added in v0.0.2

func (w *Writable) NextLine() expect.Expectation

NextLine returns an Expectation about the next line of text

func (*Writable) NextText

func (w *Writable) NextText(bytes int) expect.Expectation

NextText returns an Expectation about the next chunk of text written to the stream

func (*Writable) Size

func (w *Writable) Size() expect.Expectation

Size returns an Expectation about the number of bytes written

func (*Writable) Text

func (w *Writable) Text() expect.Expectation

Text returns an Expectation about all text written to the stream

func (*Writable) TextAt

func (w *Writable) TextAt(pos int64, bytes int) expect.Expectation

TextAt returns an Expectation about the text written at a specific position

Jump to

Keyboard shortcuts

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