コード例 #1
0
ファイル: transformer.go プロジェクト: prakashsanker/optimus
// Valuemap Applies a Valuemap transform.
func (t *Transformer) Valuemap(mappings map[string]map[interface{}]interface{}) *Transformer {
	return t.Apply(transforms.Valuemap(mappings))
}
コード例 #2
0
			return optimus.Transform(source, transforms.Select(filter))
		},
		Arg: func(row optimus.Row) (bool, error) {
			return row["header1"] == "value1", nil
		},
	},
	{
		Name:   "Valuemap",
		Source: defaultSource,
		Actual: func(source optimus.Table, arg interface{}) optimus.Table {
			mapping := arg.(map[string]map[interface{}]interface{})
			return New(source).Valuemap(mapping).Table()
		},
		Expected: func(source optimus.Table, arg interface{}) optimus.Table {
			mapping := arg.(map[string]map[interface{}]interface{})
			return optimus.Transform(source, transforms.Valuemap(mapping))
		},
		Arg: map[string]map[interface{}]interface{}{
			"header1": {"value1": "value10", "value3": "value30"},
		},
	},
	{
		Name: "TableTransformErrorPassesThrough",
		Actual: func(optimus.Table, interface{}) optimus.Table {
			return New(infinite.New()).Map(
				errorTransform("failed")).Fieldmap(map[string][]string{}).Table()
		},
		Error: errors.New("failed"),
	},
	{
		Name: "TableTransformFirstErrorPassesThrough",