github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/processors/query/operator-send-to-bus-impl_test.go (about) 1 /* 2 * Copyright (c) 2021-present unTill Pro, Ltd. 3 */ 4 5 package queryprocessor 6 7 import ( 8 "context" 9 "testing" 10 11 "github.com/stretchr/testify/require" 12 ) 13 14 func TestSendToBusOperator_DoAsync(t *testing.T) { 15 require := require.New(t) 16 counter := 0 17 operator := SendToBusOperator{ 18 rs: testResultSenderClosable{ 19 sendElement: func(name string, element interface{}) (err error) { 20 require.Equal("hello world", element.([]interface{})[0]) 21 return nil 22 }, 23 startArraySection: func(sectionType string, path []string) { 24 counter++ 25 }, 26 }, 27 metrics: &testMetrics{}, 28 } 29 work := rowsWorkpiece{outputRow: &testOutputRow{values: []interface{}{"hello world"}}} 30 31 outWork, err := operator.DoAsync(context.Background(), work) 32 _, _ = operator.DoAsync(context.Background(), work) 33 34 require.Equal(work, outWork) 35 require.NoError(err) 36 require.Equal(1, counter) 37 }