Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // IsProcessable returns true if decoder can encode/decode given file IsProcessable(file string) bool // Encode requires common file representation to encode it to data stream Encode(data []*FileDataEntry) ([]byte, error) // Decode requires data stream from file reader and decodes it into common file representation if successful Decode(data []byte) ([]*FileDataEntry, error) }
API for file decoders
type File ¶
type File struct { Path string Data []*FileDataEntry }
File is common structure of a decoded file with path and list of key-value data
func (*File) CompareTo ¶
func (f1 *File) CompareTo(f2 *File) (changed, removed []*FileDataEntry)
CompareTo compares two files - new, modified and deleted entries. Result is against the parameter.
type FileDataEntry ¶
FileDataEntry is single data record structure
type JSONDecoder ¶
type JSONDecoder struct {
// contains filtered or unexported fields
}
JSONDecoder can be used to decode json-type files
func NewJSONDecoder ¶
func NewJSONDecoder(extensions ...string) *JSONDecoder
NewJSONDecoder creates a new decoder instance
func (*JSONDecoder) Decode ¶
func (jd *JSONDecoder) Decode(byteSet []byte) ([]*FileDataEntry, error)
Decode provided byte set of json file and returns set of file data entries
func (*JSONDecoder) Encode ¶
func (jd *JSONDecoder) Encode(data []*FileDataEntry) ([]byte, error)
Encode provided file entries into JSON byte set
func (*JSONDecoder) IsProcessable ¶
func (jd *JSONDecoder) IsProcessable(file string) bool
IsProcessable returns true if decoder is able to decode provided file
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock allows to mock decoder
func NewDecoderMock ¶
func NewDecoderMock() *Mock
NewDecoderMock creates new instance of the mock and initializes response list
func (*Mock) Decode ¶
func (mock *Mock) Decode(data []byte) ([]*FileDataEntry, error)
Decode mocks original method
func (*Mock) Encode ¶
func (mock *Mock) Encode(data []*FileDataEntry) ([]byte, error)
Encode mocks original method
func (*Mock) IsProcessable ¶
IsProcessable mocks original method
type WhenResp ¶
type WhenResp struct {
// contains filtered or unexported fields
}
WhenResp is helper struct with single method call and desired response items
func (*WhenResp) ThenReturn ¶
func (when *WhenResp) ThenReturn(item ...interface{})
ThenReturn receives array of items, which are desired to be returned in mocked method defined in "When". The full logic is: - When('someMethod').ThenReturn('values')
Provided values should match return types of method. If method returns multiple values and only one is provided, mock tries to parse the value and returns it, while others will be nil or empty.
If method is called several times, all cases must be defined separately, even if the return value is the same: - When('method1').ThenReturn('val1') - When('method1').ThenReturn('val1')
All mocked methods are evaluated in same order they were assigned.
type YAMLDecoder ¶
type YAMLDecoder struct {
// contains filtered or unexported fields
}
YAMLDecoder can be used to decode yaml-type files
func NewYAMLDecoder ¶
func NewYAMLDecoder(extensions ...string) *YAMLDecoder
NewYAMLDecoder creates a new yaml decoder instance
func (*YAMLDecoder) Decode ¶
func (yd *YAMLDecoder) Decode(byteSet []byte) ([]*FileDataEntry, error)
Decode provided YAML file
func (*YAMLDecoder) Encode ¶
func (yd *YAMLDecoder) Encode(data []*FileDataEntry) ([]byte, error)
Encode provided file entries into json byte set
func (*YAMLDecoder) IsProcessable ¶
func (yd *YAMLDecoder) IsProcessable(file string) bool
IsProcessable returns true if decoder is able to decode provided file