Documentation ¶
Index ¶
- Variables
- func GRPC(rw readerWriter, dump *GRPCDump, opt *GRPCOption, hooks ...Hook[*GRPCDump]) error
- func HTTP(rw readerWriter, dump *HTTPDump, opt *HTTPOption, hooks ...HTTPHook) error
- func HTTPFile(w *http.Response, r *http.Request) readerWriter
- func JSON[T any](rw readerWriter, t T, opt *JSONOption) error
- func MarshalGRPC(d *GRPCDump) ([]byte, error)
- func MarshalHTTP(d *HTTPDump) ([]byte, error)
- func MarshalJSON[T any](t T) ([]byte, error)
- func MarshalMySQL(s *SQL) ([]byte, error)
- func MarshalPostgres(s *SQL) ([]byte, error)
- func MarshalYAML[T any](t T) ([]byte, error)
- func MySQL(rw readerWriter, sql *SQL, opt *MySQLOption, hooks ...Hook[*SQL]) error
- func Postgres(rw readerWriter, sql *SQL, opt *PostgresOption, hooks ...Hook[*SQL]) error
- func Snapshot[T any](rw readerWriter, t T, s S[T]) error
- func Text(rw readerWriter, received string) error
- func UnmarshalJSON[T any](b []byte) (T, error)
- func UnmarshalYAML[T any](b []byte) (T, error)
- func YAML[T any](rw readerWriter, t T, opt *YAMLOption) error
- type CUEOption
- type CompareAnyFunc
- type CompareFunc
- type DiffError
- type File
- type GRPCComparer
- type GRPCDump
- type GRPCOption
- type HTTPComparer
- type HTTPDump
- type HTTPHook
- type HTTPOption
- type Hook
- func CompareHook[T any](hook func(snapshot T, received T) error) Hook[T]
- func Copier[T any]() Hook[T]
- func MarshalHook[T any](hook func(T) (T, error)) Hook[T]
- func MaskMessage(fields ...string) Hook[*GRPCDump]
- func MaskMetadata(headers ...string) Hook[*GRPCDump]
- func MaskRequestBody(fields ...string) Hook[*HTTPDump]
- func MaskRequestHeaders(headers ...string) Hook[*HTTPDump]
- func MaskResponseBody(fields ...string) Hook[*HTTPDump]
- func MaskResponseHeaders(headers ...string) Hook[*HTTPDump]
- type Hooks
- type InMemory
- type JSONComparer
- type JSONOption
- type MarshalFunc
- type MySQLComparer
- type MySQLOption
- type PostgresComparer
- type PostgresOption
- type RoundTripper
- type S
- type SQL
- type TxTar
- type UnmarshalAnyFunc
- type UnmarshalFunc
- type YAMLComparer
- type YAMLOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrHeaderNotFound = errors.New("testdump: HTTP header not found")
View Source
var ErrMetadataNotFound = errors.New("testdump: gRPC metadata not found")
Functions ¶
func GRPC ¶
func GRPC(rw readerWriter, dump *GRPCDump, opt *GRPCOption, hooks ...Hook[*GRPCDump]) error
func HTTPFile ¶
HTTPFile returns a filename based on the http request method and response status code.
func JSON ¶
func JSON[T any](rw readerWriter, t T, opt *JSONOption) error
NOTE: Why using a type is bad - because if we serialize to structs, the keys that are removed won't be compared. Ideally, using map[string]any or just any should work better for snapshot testing.
func MarshalGRPC ¶
func MarshalHTTP ¶
func MarshalJSON ¶
func MarshalMySQL ¶
func MarshalPostgres ¶
func MarshalYAML ¶
func Postgres ¶
func Postgres(rw readerWriter, sql *SQL, opt *PostgresOption, hooks ...Hook[*SQL]) error
func UnmarshalJSON ¶
The problem is here - the unmarshalling actually causes a loss of data.
func UnmarshalYAML ¶
func YAML ¶
func YAML[T any](rw readerWriter, t T, opt *YAMLOption) error
Types ¶
type CUEOption ¶
type CompareAnyFunc ¶
func (CompareAnyFunc) CompareAny ¶
func (f CompareAnyFunc) CompareAny(a, b any) error
type CompareFunc ¶
func (CompareFunc[T]) Compare ¶
func (f CompareFunc[T]) Compare(a, b T) error
type DiffError ¶
func AsDiffError ¶
type GRPCComparer ¶
func (GRPCComparer) Compare ¶
func (c GRPCComparer) Compare(snapshot, received *GRPCDump) error
type GRPCDump ¶
func UnmarshalGRPC ¶
type HTTPComparer ¶
func (HTTPComparer) Compare ¶
func (c HTTPComparer) Compare(snapshot, received *HTTPDump) error
type HTTPDump ¶
func UnmarshalHTTP ¶
type HTTPOption ¶
type Hook ¶
func CompareHook ¶
func MarshalHook ¶
func MaskMessage ¶
func MaskMetadata ¶
func MaskRequestBody ¶
func MaskRequestHeaders ¶
func MaskResponseBody ¶
func MaskResponseHeaders ¶
type InMemory ¶
func NewInMemory ¶
func NewInMemory() *InMemory
type JSONComparer ¶
func (*JSONComparer[T]) Compare ¶
func (c *JSONComparer[T]) Compare(snapshot, received T) error
type JSONOption ¶
type MarshalFunc ¶
func (MarshalFunc[T]) Marshal ¶
func (f MarshalFunc[T]) Marshal(t T) ([]byte, error)
type MySQLComparer ¶
func (*MySQLComparer) Compare ¶
func (cmp *MySQLComparer) Compare(snapshot, received *SQL) error
type MySQLOption ¶
type PostgresComparer ¶
func (*PostgresComparer) Compare ¶
func (cmp *PostgresComparer) Compare(snapshot, received *SQL) error
type PostgresOption ¶
type RoundTripper ¶
type RoundTripper struct { RoundTripper http.RoundTripper // contains filtered or unexported fields }
func NewRoundTripper ¶
func NewRoundTripper(rwFunc readerWriterFunc, opt *HTTPOption, hooks ...HTTPHook) *RoundTripper
type UnmarshalAnyFunc ¶
func (UnmarshalAnyFunc) UnmarshalAny ¶
func (f UnmarshalAnyFunc) UnmarshalAny(b []byte) (any, error)
type UnmarshalFunc ¶
func (UnmarshalFunc[T]) Unmarshal ¶
func (f UnmarshalFunc[T]) Unmarshal(b []byte) (T, error)
type YAMLComparer ¶
func (*YAMLComparer[T]) Compare ¶
func (c *YAMLComparer[T]) Compare(snapshot, received T) error
Click to show internal directories.
Click to hide internal directories.