Esempio 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)
}
Esempio n. 2
0
func TestRightTableTransformError(t *testing.T) {
	leftTable := slice.New([]optimus.Row{
		{"header1": "value1", "header2": "value2"},
	})
	rightTable := slice.New([]optimus.Row{{"": ""}})

	// Returns an error immediately
	rightTable = optimus.Transform(rightTable, TableTransform(func(row optimus.Row, out chan<- optimus.Row) error {
		return errors.New("some error")
	}))
	combinedTable := optimus.Transform(leftTable, Join(rightTable, "header1", "header3", JoinType.Inner))

	// Should receive no rows here because the first response was an error.
	tests.Consumed(t, combinedTable)
	// Should receive no rows here because the the transform should have consumed
	// all the rows.
	tests.Consumed(t, rightTable)

	if combinedTable.Err() == nil {
		t.Fatal("Expected RightTable to report an error")
	}
}