Exemplo n.º 1
0
// TestTransformError tests that the upstream Table had all of its data consumed in the case of an
// error from a TableTransform.
func TestTransformError(t *testing.T) {
	in := infinite.New()
	out := optimus.Transform(in, TableTransform(func(row optimus.Row, out chan<- optimus.Row) error {
		return errors.New("some error")
	}))
	// Should receive no rows here because the first response was an error.
	tests.Consumed(t, out)
	// Should receive no rows here because the the transform should have consumed
	// all the rows.
	tests.Consumed(t, in)
}
Exemplo n.º 2
0
		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",
		Actual: func(optimus.Table, interface{}) optimus.Table {
			return New(infinite.New()).Map(
				errorTransform("failed1")).Map(errorTransform("failed2")).Table()
		},
		Error: errors.New("failed1"),
	},
}

// TestEquality tests that the chained version and non-chained version of a transform