helpertest

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	A     = dns.Type(dns.TypeA)
	AAAA  = dns.Type(dns.TypeAAAA)
	CNAME = dns.Type(dns.TypeCNAME)
	HTTPS = dns.Type(dns.TypeHTTPS)
	MX    = dns.Type(dns.TypeMX)
	PTR   = dns.Type(dns.TypePTR)
	SRV   = dns.Type(dns.TypeSRV)
	TXT   = dns.Type(dns.TypeTXT)
	DS    = dns.Type(dns.TypeDS)
)

Variables

This section is empty.

Functions

func BeDNSRecord

func BeDNSRecord(domain string, dnsType dns.Type, answer string) types.GomegaMatcher

BeDNSRecord returns new dns matcher

func DoGetRequest

func DoGetRequest(ctx context.Context, url string,
	fn func(w http.ResponseWriter, r *http.Request),
) (*httptest.ResponseRecorder, *bytes.Buffer)

DoGetRequest performs a GET request

func GetHostPort

func GetHostPort(host string, port int) string

GetHostPort returns a host:port string for the current testing process by adding the current ginkgo parallel process to the base port and returning it as string.

func GetIntPort

func GetIntPort(port int) int

GetIntPort returns a port for the current testing process by adding the current ginkgo parallel process to the base port and returning it as int.

func GetStringPort

func GetStringPort(port int) string

GetStringPort returns a port for the current testing process by adding the current ginkgo parallel process to the base port and returning it as string.

func HaveAuthority added in v0.28.0

func HaveAuthority() types.GomegaMatcher

func HaveEdnsOption

func HaveEdnsOption(code uint16) types.GomegaMatcher

HaveEdnsOption checks if the given message contains an EDNS0 record with the given option code.

func HaveNoAnswer

func HaveNoAnswer() types.GomegaMatcher

func HaveReason

func HaveReason(reason string) types.GomegaMatcher

func HaveResponseType

func HaveResponseType(c model.ResponseType) types.GomegaMatcher

func HaveReturnCode

func HaveReturnCode(code int) types.GomegaMatcher

func HaveSOARecord added in v0.28.0

func HaveSOARecord(ttl, minTTL uint32) types.GomegaMatcher

func HaveTTL

func HaveTTL(matcher types.GomegaMatcher) types.GomegaMatcher

func TempFile

func TempFile(data string) *os.File

TempFile creates temp file with passed data

func TestServer

func TestServer(data string) *httptest.Server

TestServer creates temp http server with passed data

func ToAnswer

func ToAnswer(m *model.Response) []dns.RR

func ToAuthority added in v0.28.0

func ToAuthority(m *model.Response) []dns.RR

func ToExtra

func ToExtra(m *model.Response) []dns.RR

Types

type HTTPProxy

type HTTPProxy struct {
	Addr net.Addr
	// contains filtered or unexported fields
}

func TestHTTPProxy

func TestHTTPProxy() *HTTPProxy

TestHTTPProxy returns a new HTTPProxy server.

All requests return http.StatusNotImplemented.

func (*HTTPProxy) ReqURL

func (p *HTTPProxy) ReqURL(*http.Request) (*url.URL, error)

func (*HTTPProxy) RequestTarget

func (p *HTTPProxy) RequestTarget() string

RequestTarget returns the target of the last request.

func (*HTTPProxy) ServeHTTP

func (p *HTTPProxy) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*HTTPProxy) URL

func (p *HTTPProxy) URL() *url.URL

URL returns the proxy's URL for use by clients.

type MockCallSequence

type MockCallSequence[T any] struct {
	// contains filtered or unexported fields
}

func NewMockCallSequence

func NewMockCallSequence[T any](driver func(chan<- T, chan<- error)) MockCallSequence[T]

func (*MockCallSequence[T]) Call

func (m *MockCallSequence[T]) Call() (T, error)

func (*MockCallSequence[T]) CallCount

func (m *MockCallSequence[T]) CallCount() uint

func (*MockCallSequence[T]) Close

func (m *MockCallSequence[T]) Close()

type TmpFile

type TmpFile struct {
	Path   string
	Folder *TmpFolder
}

type TmpFolder

type TmpFolder struct {
	Path string
	// contains filtered or unexported fields
}

func NewTmpFolder

func NewTmpFolder(prefix string) *TmpFolder

func (*TmpFolder) Clean

func (tf *TmpFolder) Clean() error

func (*TmpFolder) CreateEmptyFile

func (tf *TmpFolder) CreateEmptyFile(name string) *TmpFile

func (*TmpFolder) CreateStringFile

func (tf *TmpFolder) CreateStringFile(name string, lines ...string) *TmpFile

func (*TmpFolder) CreateSubFolder

func (tf *TmpFolder) CreateSubFolder(name string) *TmpFolder

func (*TmpFolder) JoinPath

func (tf *TmpFolder) JoinPath(name string) string

Jump to

Keyboard shortcuts

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