...

Package golden

Overview ▾

type Entry

Entry is the golden file single entry.

type Entry struct {
    Timestamp  int64           `json:"timestamp"`
    Value      json.RawMessage `json:"value"`
    ResultSize int64           `json:"resultSize,omitempty"`
    Allocs     int64           `json:"allocs,omitempty"`
    Mallocs    int64           `json:"mallocs,omitempty"`
    Invalid    bool            `json:"markedInvalid,omitempty"`
}

type File

File represents the golden file hash map.

type File struct {
    Timestamp time.Time `json:"timestamp"`
    Map       *Map      `json:"map,omitempty"`
    // contains filtered or unexported fields
}

func ReadFile

func ReadFile(dirPath, testName string, createEmpty bool) (*File, error)

ReadFile reads the golden file map stored at the 'path'. The 'createEmpty' flag creates empty file if there is no golden stored at provided 'path'.

func (*File) Update

func (f *File) Update(currentMap *Map) error

Update updates given golden file.

type Map

Map is the golden file

type Map struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func (*Map) Compare

func (m *Map) Compare(current *Map, parallel bool) []MismatchedEntry

Compare reads and checks all values from the source map 'm' against runtime map 'd' and returns mismatched entries.

func (*Map) Copy

func (m *Map) Copy() *Map

Copy creates a copy of given golden file map.

func (*Map) Keys

func (m *Map) Keys() (keys []string)

Keys gets the keys of given map.

func (*Map) Len

func (m *Map) Len() int

Len returns the length of given map.

func (*Map) MarshalJSON

func (m *Map) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Map) Read

func (m *Map) Read(key string) (Entry, bool)

func (*Map) UnmarshalJSON

func (m *Map) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

func (*Map) Write

func (m *Map) Write(key string, entry Entry)

Write write new entry for given key value.

type MismatchedEntries

MismatchedEntries is the slice wrapper over mismatched compare entries.

type MismatchedEntries []MismatchedEntry

type MismatchedEntry

MismatchedEntry is the unsuccessful result of the map compare function.

type MismatchedEntry struct {
    Key      string `json:"key,omitempty"`
    NotFound bool   `json:"notFound,omitempty"`
    Expected Entry  `json:"expected,omitempty"`
    Current  Entry  `json:"current,omitempty"`
}

func (MismatchedEntry) String

func (m MismatchedEntry) String() string