Entry is the golden file single entry.
type Entry struct { Timestamp int64 `json:"timestamp"` Value string `json:"value"` ResultSize int64 `json:"resultSize,omitempty"` Allocs int64 `json:"allocs,omitempty"` Mallocs int64 `json:"mallocs,omitempty"` Invalid bool `json:"markedInvalid,omitempty"` }
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(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 (f *File) Update(currentMap *Map) error
Update updates given golden file.
Map is the golden file
type Map struct { sync.Mutex // contains filtered or unexported fields }
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 (m *Map) Copy() *Map
Copy creates a copy of given golden file map.
func (m *Map) Keys() (keys []string)
Keys gets the keys of given map.
func (m *Map) Len() int
Len returns the length of given map.
func (m *Map) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (m *Map) Read(key string) (Entry, bool)
func (m *Map) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
func (m *Map) Write(key string, entry Entry)
Write write new entry for given key value.
MismatchedEntries is the slice wrapper over mismatched compare entries.
type MismatchedEntries []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 (m MismatchedEntry) String() string