Ejemplo n.º 1
0
// Map Applies a Map transform.
func (t *Transformer) Map(transform func(optimus.Row) (optimus.Row, error)) *Transformer {
	return t.Apply(transforms.Map(transform))
}
Ejemplo n.º 2
0
		Expected: func(source optimus.Table, arg interface{}) optimus.Table {
			mappings := arg.(map[string][]string)
			return optimus.Transform(source, transforms.Fieldmap(mappings))
		},
		Arg: map[string][]string{"header1": {"header4"}},
	},
	{
		Name:   "Map",
		Source: defaultSource,
		Actual: func(source optimus.Table, arg interface{}) optimus.Table {
			transform := arg.(func(optimus.Row) (optimus.Row, error))
			return New(source).Map(transform).Table()
		},
		Expected: func(source optimus.Table, arg interface{}) optimus.Table {
			transform := arg.(func(optimus.Row) (optimus.Row, error))
			return optimus.Transform(source, transforms.Map(transform))
		},
		Arg: func(row optimus.Row) (optimus.Row, error) {
			return optimus.Row{}, nil
		},
	},
	{
		Name:   "Table",
		Source: defaultSource,
		Actual: func(source optimus.Table, arg interface{}) optimus.Table {
			transform := arg.(func(optimus.Row, chan<- optimus.Row) error)
			return New(source).TableTransform(transform).Table()
		},
		Expected: func(source optimus.Table, arg interface{}) optimus.Table {
			transform := arg.(func(optimus.Row, chan<- optimus.Row) error)
			return optimus.Transform(source, transforms.TableTransform(transform))