test

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MockCredential azcore.TokenCredential = &testCredential{}

Functions

func Base64ToBigInt added in v0.7.0

func Base64ToBigInt(s string) *big.Int

Base64ToBigInt decodes a base64 string to a big.Int.

func Base64ToBytes added in v0.7.0

func Base64ToBytes(s string) []byte

test.Base64ToBytes decodes a base64 string to a []byte.

func Hash added in v0.7.0

func Hash(plaintext string, hash crypto.Hash) []byte

Hash a plaintext string using SHA256.

func HexToBytes added in v0.7.0

func HexToBytes(s string) []byte

HexToBytes decodes a hexadecimal string to a []byte.

func IsRemoteOnly

func IsRemoteOnly() bool

func Recorded

func Recorded[T any](t *testing.T, factory ClientFactory[T]) *T

func RequireIfResponseError

func RequireIfResponseError(t *testing.T, err error, target error) bool

func URLJoinPath

func URLJoinPath(base string, elem ...string) (string, error)

Types

type ClientFactory

type ClientFactory[T any] func(*Recording) (*T, error)

type Rand added in v0.7.0

type Rand struct{}

Rand is a mock RNG used only for testing.

func (*Rand) Read added in v0.7.0

func (r *Rand) Read(b []byte) (int, error)

type Recording

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

func (*Recording) GetCredential

func (r *Recording) GetCredential() azcore.TokenCredential

func (*Recording) GetTransport

func (r *Recording) GetTransport() policy.Transporter

func (*Recording) IsPassthrough

func (r *Recording) IsPassthrough() bool

func (*Recording) OverrideResponse

func (r *Recording) OverrideResponse(override RecordingOverride)

type RecordingOverride

type RecordingOverride func(req *http.Request, resp *http.Response) (code int, body string)

Jump to

Keyboard shortcuts

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