specimen

package module
v0.0.0-...-10d77c3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

README

Code Overview

/go/specimen

  • file.go is about local files and virtual files
  • flag.go allows to read the flags on a YAML node
  • init.go sets global objects and configurations
  • nodule.go implements methods and functions related to the Nodule struct
  • run.go implements the entry point to the library: "specimen.Run(...)"
  • structure.go contains all the type declarations
  • testcontext.go contains the methods specified on the testcontext
  • tree.go implements the focustree.Node interface on the Nodule and NoduleRoot types

The .InitializeTree() method is run on all nodules of the tree. .Populate() excludes the nodes carrying the "PENDING" flag.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, boxFunction BoxFunction, fileSlice []File)

Load the data of the given files and runs the code sandboxes with it

Types

type BoxFunction

type BoxFunction func(s *S, tile Dict)

BoxFunction is the type that user-defined functions must implement in the testbox

type Dict

type Dict = map[string]string

Dict is a shorthand for map of string to string

type FailStatus

type FailStatus int

FailStatus specifies the kind of failure a slab produced, if any

const (
	Pristine FailStatus = iota
	Failed
	Aborted
	Panicked
)

type File

type File struct {
	Path    string
	Content []byte
}

File represents a file by its path and content

func ReadLocalFile

func ReadLocalFile(path string) File

ReadLocalFile reads a file from the file system and returns a specimen.File

func VirtualFile

func VirtualFile(imaginaryPath string, content []byte) File

VirtualFile creates a specimen.File from scratch

func VirtualFileDedent

func VirtualFileDedent(imaginaryPath string, content []byte) File

VirtualFileDedent dedents the given content and creates a specimen.File

type Nodule

type Nodule struct {
	FilePath      string
	YamlNode      *yaml.Node
	Flag          focustree.FlagType
	HasContentKey bool
	Children      []Nodule
	DataMatrix    orderedstringmap.OSM
}

Nodule is a node inside a file

func NewNoduleFromFile

func NewNoduleFromFile(file File) (n Nodule, err error)

func (Nodule) Errorf

func (n Nodule) Errorf(format string, a ...interface{}) error

func (Nodule) GetChildren

func (n Nodule) GetChildren() (children []focustree.Node)

func (Nodule) GetFlag

func (n Nodule) GetFlag() focustree.FlagType

func (*Nodule) GetLocation

func (n *Nodule) GetLocation() string

func (*Nodule) InitializeTree

func (n *Nodule) InitializeTree() (err error)

The initialization creates all the nodules corresponding to the mapping nodes of the yaml tree, except for the PENDING nodes. It fills the fields Flag, HasContentKey and Children. **It expects YamlNode and FilePath to be already set**, and it sets YamlNode and FilePath for its children.

func (Nodule) IsLeaf

func (n Nodule) IsLeaf() bool

func (*Nodule) NewResolveDataMatrixIterator

func (n *Nodule) NewResolveDataMatrixIterator() func() Dict

func (*Nodule) Populate

func (n *Nodule) Populate(dataMatrix orderedstringmap.OSM) (err error)

Populate fills the DataMatrix with the Yaml data

func (Nodule) Warning

func (n Nodule) Warning(info string)

type NoduleRoot

type NoduleRoot []Nodule

NoduleRoot is used to gather the files for exploration by the focustree package

func (NoduleRoot) GetChildren

func (t NoduleRoot) GetChildren() (children []focustree.Node)

func (NoduleRoot) GetFlag

func (NoduleRoot) GetFlag() focustree.FlagType

func (NoduleRoot) IsLeaf

func (NoduleRoot) IsLeaf() bool

func (NoduleRoot) Warning

func (NoduleRoot) Warning(info string)

type S

type S struct {
	T *testing.T
	// contains filtered or unexported fields
}

S is a context structure for the Specimen package. It is preseved from the run of a slab to the next

func (*S) Abort

func (s *S) Abort(info string)

Abort marks the slab as aborted and saves the given information, if provided.

func (*S) ExpectEqual

func (s *S) ExpectEqual(value, wanted interface{}, context string)

ExpectEqual tests if the two given values are equal data structures

func (*S) Fail

func (s *S) Fail(info string)

Fail marks the slab as failed and saves the given information, if provided. It can be called multiple times for a single slab. All saved information will be reported.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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