Ejemplo n.º 1
0
// Fieldmap Applies a Fieldmap transform.
func (t *Transformer) Fieldmap(mappings map[string][]string) *Transformer {
	return t.Apply(transforms.Fieldmap(mappings))
}
Ejemplo n.º 2
0
		map[string][]string{"header1": {"header3"}}).Fieldmap(map[string][]string{"header3": {"header4"}}).Table()
	rows := tests.HasRows(t, transformedTable, 3)
	assert.Equal(t, expected, rows)
}

var chainedEqualities = []tests.TableCompareConfig{
	{
		Name:   "Fieldmap",
		Source: defaultSource,
		Actual: func(source optimus.Table, arg interface{}) optimus.Table {
			mappings := arg.(map[string][]string)
			return New(source).Fieldmap(mappings).Table()
		},
		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) {