mock

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package mock contains mock implementations used across multiple packages within autoreverse. Mocks unique to a particular package stay within their own package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNetAddr added in v1.1.0

func NewNetAddr(networkStr, stringStr string) *netAddr

NewNetAddr creates a mock net.Addr with return values for Network() and String()

Types

type IOWriter

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

IOWriter is a mock replacement for any place that accepts an io.Writer. Only used by test programs, it appends each write to a []byte slice and makes it available via the String() function. In the case of autoreverse, it's most often used to replace the log package output to capture logging activity and compare it against expected.

func (*IOWriter) Len

func (t *IOWriter) Len() int

Len is a helper function which returns the size of the byte slice.

func (*IOWriter) Reset

func (t *IOWriter) Reset()

Reset clears the byte slice such that String() will now return an empty string.

func (*IOWriter) String

func (t *IOWriter) String() string

String returns the complete byte slice as a string. The byte slice is not changed by this function call. If you want the slice to be reset, called the Reset() function.

func (*IOWriter) Write

func (t *IOWriter) Write(b []byte) (int, error)

Write helps meet the io.Writer interface. Is appends the bytes to the internal byte slice.

type ResponseWriter

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

ResponseWriter is a mock replacement for the miekg dns.ResponseWriter. It's used for tests only. It contains a response message that is arbitrarily returned.

func (*ResponseWriter) Close

func (t *ResponseWriter) Close() (e error)

Close helps meet the dns.ResponseWriter interface. It is a no-op.

func (*ResponseWriter) Get

func (t *ResponseWriter) Get() *dns.Msg

Get returns the last response, if any then clears the response

func (*ResponseWriter) Hijack

func (t *ResponseWriter) Hijack()

Hijack helps meet the dns.ResponseWriter interface. It is a no-op.

func (*ResponseWriter) LocalAddr

func (t *ResponseWriter) LocalAddr() (a net.Addr)

LocalAddr helps meet the dns.ResponseWriter interface

func (*ResponseWriter) RemoteAddr

func (t *ResponseWriter) RemoteAddr() (r net.Addr)

RemoteAddr helps meet the dns.ResponseWriter interface

func (*ResponseWriter) Reset

func (t *ResponseWriter) Reset()

Reset clears the response message

func (*ResponseWriter) TsigStatus

func (t *ResponseWriter) TsigStatus() (e error)

TsigStatus helps meet the dns.ResponseWriter interface. It is a no-op.

func (*ResponseWriter) TsigTimersOnly

func (t *ResponseWriter) TsigTimersOnly(bool)

TsigTimersOnly helps meet the dns.ResponseWriter interface. It is a no-op.

func (*ResponseWriter) Write

func (t *ResponseWriter) Write(b []byte) (l int, e error)

Write helps meet the dns.ResponseWriter interface

func (*ResponseWriter) WriteMsg

func (t *ResponseWriter) WriteMsg(m *dns.Msg) (e error)

WriteMsg helps meet the dns.ResponseWriter interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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