htmltest

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package htmltest provides a set of tools for testing rendered HTML page elements.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateValue = errors.New("duplicate value")
)

Functions

func IsLocalURL added in v0.0.3

func IsLocalURL(s string) bool

func IsPadding

func IsPadding(n *html.Node) bool

func JoinURL added in v0.0.3

func JoinURL(base, path string) (string, error)

func NewMatchError

func NewMatchError(path []string, cause error) error

func ParseAttributes

func ParseAttributes(node *html.Node) (map[string]string, error)

func ParseCommaSeparatedKeyedValues

func ParseCommaSeparatedKeyedValues(s string) (map[string]string, error)

func ParseTextContent

func ParseTextContent(node *html.Node) string

func Path added in v0.0.2

func Path(node *html.Node) string

Types

type MatchError

type MatchError struct {
	Path  []string
	Cause error
}

func (MatchError) Error

func (e MatchError) Error() string

func (MatchError) Unwrap

func (e MatchError) Unwrap() error

type Middleware added in v0.0.3

type Middleware interface {
	Wrap(Validator) Validator
}
var SkipMiddleware Middleware = skipSingleton

SkipMiddleware is a middleware that does nothing.

func NewDeduplicator added in v0.0.3

func NewDeduplicator(nameSpace string) Middleware

type MiddlewareFunc added in v0.0.3

type MiddlewareFunc func(Validator) Validator

func (MiddlewareFunc) Wrap added in v0.0.3

type Node

type Node struct {
	Name       string
	Content    Validator
	Attributes map[string]Validator
	Children   []Node
}

func (Node) Match

func (n Node) Match(x *html.Node, path []string) (err error)

type Validator

type Validator interface {
	Validate(string) error
}
var SkipValidator Validator = skipSingleton

SkipValidator is a validator that never returns an error. It is a sentinel value used to skip validation tests and reduce the verbosity of test output.

func NewExactMatch

func NewExactMatch(expected string) Validator

NewExactMatch creates a validator that checks if the input string matches the expected string.

func NewURLValidator added in v0.0.3

func NewURLValidator(client *http.Client, acceptStatusCodes ...int) Validator

type ValidatorFunc

type ValidatorFunc func(string) error

func (ValidatorFunc) Validate

func (f ValidatorFunc) Validate(s string) error

Jump to

Keyboard shortcuts

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