github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/pipeline/sync_test.go (about)

     1  // Copyright (c) 2021-present Voedger Authors.
     2  // This source code is licensed under the MIT license found in the
     3  // LICENSE file in the root directory of this source tree.
     4  // @author Michael Saigachenko
     5  
     6  package pipeline
     7  
     8  import (
     9  	"context"
    10  	"errors"
    11  	"testing"
    12  
    13  	"github.com/stretchr/testify/require"
    14  )
    15  
    16  func opName(_ context.Context, work interface{}) (err error) {
    17  	work.(testwork).slots["name"] = "michael"
    18  	return nil
    19  }
    20  
    21  func opAge(_ context.Context, work interface{}) (err error) {
    22  	work.(testwork).slots["age"] = "39"
    23  	return nil
    24  }
    25  
    26  func opSex(_ context.Context, work interface{}) (err error) {
    27  	work.(testwork).slots["sex"] = "male"
    28  	return nil
    29  }
    30  
    31  func opError(context.Context, interface{}) (err error) {
    32  	return errors.New("test failure")
    33  }
    34  
    35  func TestSyncPipeline_NotAWorkpiece(t *testing.T) {
    36  	type notAWorkpiece struct{}
    37  	ctx := &testContext{}
    38  	v := &notAWorkpiece{}
    39  	pipeline := NewSyncPipeline(ctx, "my-pipeline", WireSyncOperator("noop", &NOOP{}))
    40  	require.NoError(t, pipeline.DoSync(ctx, v))
    41  }