Beispiel #1
0
func TestPairErrorsRightTable(t *testing.T) {
	left := slice.New([]optimus.Row{a, b, c})
	right := errorSource.New(fmt.Errorf("garbage error"))

	table := optimus.Transform(left, Pair(right, KeyIdentifier(""), KeyIdentifier(""), OuterJoin))
	tests.Consumed(t, table)
	tests.Consumed(t, right)
	assert.EqualError(t, table.Err(), "garbage error")
}
Beispiel #2
0
func TestJoinErrors(t *testing.T) {
	left := slice.New([]optimus.Row{a, b, c})
	right := errorTable.New(fmt.Errorf("garbage error"))

	table := optimus.Transform(left, Join(right, "", "", JoinType.Left))
	tests.Consumed(t, table)
	tests.Consumed(t, right)
	assert.EqualError(t, table.Err(), "garbage error")
}
Beispiel #3
0
func TestPairErrorsRowIdentifier(t *testing.T) {
	for _, joinHasherError := range joinHasherErrors {
		left := slice.New(joinHasherError.left)
		right := slice.New(joinHasherError.right)

		table := optimus.Transform(left, Pair(right, joinHasherError.leftID, joinHasherError.rightID, OuterJoin))
		tests.Consumed(t, table)
		tests.Consumed(t, right)
		assert.EqualError(t, table.Err(), joinHasherError.expected)
	}
}
Beispiel #4
0
func TestUniqueErrorForInvalidHeader(t *testing.T) {
	inputTable := slice.New([]optimus.Row{
		{"header1": "value1", "header2": "value2"},
	})
	actualTable := optimus.Transform(inputTable, Unique(invalidHeaderHash))
	tests.Consumed(t, actualTable)
	if actualTable.Err() == nil {
		t.Fatal("Expected actualTable to report an error")
	}
}
Beispiel #5
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) {
	for i := 0; i < 5; i++ {
		in := infinite.New()
		out := in
		for j := 0; j < i; j++ {
			out = optimus.Transform(out, Each(func(optimus.Row) error {
				return nil
			}))
		}
		out = optimus.Transform(out, TableTransform(func(row optimus.Row, out chan<- optimus.Row) error {
			return errors.New("some error")
		}))
		for j := i; j < 5; j++ {
			out = optimus.Transform(out, Each(func(optimus.Row) error {
				return nil
			}))
		}
		assert.EqualError(t, discard.Discard(out), "some error")
		tests.Consumed(t, in)
	}
}