beacontest

package
v3.0.0-alpha5.0...-c974331 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpressionMustReturnBool = errors.New("cel expression must return bool")
	ErrUnknownType              = errors.New("unknown type")
)

Functions

func Execute

func Execute(options ...HarnessOption)

func NewBasePathFs

func NewBasePathFs(source afero.Fs, path string) afero.Fs

func WithFilesystem

func WithFilesystem(name string, handler afero.Fs) func(*Harness) error

func WithHandler

func WithHandler(name string, handler http.Handler) func(*Harness) error

func WithTestFromBytes

func WithTestFromBytes(name string, xs []byte) func(*Harness) error

func WithTestFromFs

func WithTestFromFs(fs afero.Fs, name string) func(*Harness) error

func WithTesting

func WithTesting(t *testing.T) func(*Harness) error

func WithTests

func WithTests(name string, xs []Test) func(*Harness) error

Types

type BasePathFile

type BasePathFile struct {
	afero.File
	// contains filtered or unexported fields
}

func (*BasePathFile) Name

func (f *BasePathFile) Name() string

func (*BasePathFile) ReadDir

func (f *BasePathFile) ReadDir(n int) ([]fs.DirEntry, error)

type BasePathFs

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

This is a version of the afero basepathfs that uses path instead of filepath. this is needed to work with things like zipfs and embedfs on windows

func (*BasePathFs) Chmod

func (b *BasePathFs) Chmod(name string, mode os.FileMode) (err error)

func (*BasePathFs) Chown

func (b *BasePathFs) Chown(name string, uid, gid int) (err error)

func (*BasePathFs) Chtimes

func (b *BasePathFs) Chtimes(name string, atime, mtime time.Time) (err error)

func (*BasePathFs) Create

func (b *BasePathFs) Create(name string) (f afero.File, err error)

func (*BasePathFs) LstatIfPossible

func (b *BasePathFs) LstatIfPossible(name string) (os.FileInfo, bool, error)

func (*BasePathFs) Mkdir

func (b *BasePathFs) Mkdir(name string, mode os.FileMode) (err error)

func (*BasePathFs) MkdirAll

func (b *BasePathFs) MkdirAll(name string, mode os.FileMode) (err error)

func (*BasePathFs) Name

func (b *BasePathFs) Name() string

func (*BasePathFs) Open

func (b *BasePathFs) Open(name string) (f afero.File, err error)

func (*BasePathFs) OpenFile

func (b *BasePathFs) OpenFile(name string, flag int, mode os.FileMode) (f afero.File, err error)

func (*BasePathFs) ReadlinkIfPossible

func (b *BasePathFs) ReadlinkIfPossible(name string) (string, error)

func (*BasePathFs) RealPath

func (b *BasePathFs) RealPath(name string) (p string, err error)

on a file outside the base path it returns the given file name and an error, else the given file with the base path prepended

func (*BasePathFs) Remove

func (b *BasePathFs) Remove(name string) (err error)

func (*BasePathFs) RemoveAll

func (b *BasePathFs) RemoveAll(name string) (err error)

func (*BasePathFs) Rename

func (b *BasePathFs) Rename(oldname, newname string) (err error)

func (*BasePathFs) Stat

func (b *BasePathFs) Stat(name string) (fi os.FileInfo, err error)

func (*BasePathFs) SymlinkIfPossible

func (b *BasePathFs) SymlinkIfPossible(oldname, newname string) error

type Comparison

type Comparison struct {
	Expr    string   `json:"expr"`
	Exprs   []string `json:"exprs"`
	Literal bool     `json:"literal"`
}

func (*Comparison) Compare

func (c *Comparison) Compare(t *testing.T, aRaw, bRaw json.RawMessage, aCode, bCode int) error

type Extra

type Extra struct {
	Vars map[string]any `json:"vars"`

	RawBodyZZZZ json.RawMessage `json:"tests"`
}

type Harness

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

func (*Harness) Execute

func (h *Harness) Execute()

type HarnessOption

type HarnessOption func(*Harness) error

type Source

type Source struct {

	// remote type
	Remote  *string           `json:"remote,omitempty"`
	Handler *string           `json:"handler,omitempty"`
	Method  string            `json:"method"`
	Path    string            `json:"path"`
	Query   map[string]string `json:"query"`
	Headers map[string]string `json:"headers"`
	Body    *Source           `json:"body,omitempty"`

	// data type
	Data any `json:"data,omitempty"`

	// file type
	File *string `json:"file,omitempty"`
	Fs   string  `json:"fs,omitempty"`

	// for raw type
	Raw *string `json:"raw,omitempty"`
	// contains filtered or unexported fields
}

func (*Source) Execute

func (s *Source) Execute(ctx context.Context) (json.RawMessage, int, error)

type Test

type Test struct {
	Name    string     `json:"name"`
	Expect  Source     `json:"expect"`
	Actual  Source     `json:"actual"`
	Compare Comparison `json:"compare"`
}

func (*Test) Execute

func (c *Test) Execute(ctx context.Context, t *testing.T) error

Jump to

Keyboard shortcuts

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