Skip to content

Commit 8461215

Browse files
beelisnodece
authored andcommitted
Update pulsar-function-go/pf/context_test.go
Co-authored-by: Zixuan Liu <[email protected]>
1 parent 8111741 commit 8461215

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pulsar-function-go/pf/context_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func TestFunctionContext_NewOutputMessage(t *testing.T) {
8686
}
8787

8888
func TestFunctionContext_NewOutputMessageWithError(t *testing.T) {
89-
9089
testCases := []struct {
9190
name string
9291
outputFunc func(topic string) (pulsar.Producer, error)
@@ -102,7 +101,7 @@ func TestFunctionContext_NewOutputMessageWithError(t *testing.T) {
102101
{
103102
name: "Test error",
104103
outputFunc: func(topic string) (pulsar.Producer, error) { return nil, errors.New("test error") },
105-
expectedError: false,
104+
expectedError: true,
106105
expectedProducerType: nil,
107106
},
108107
}
@@ -113,12 +112,14 @@ func TestFunctionContext_NewOutputMessageWithError(t *testing.T) {
113112
fc := NewFuncContext()
114113
publishTopic := "publish-topic"
115114

116-
fc.outputMessageWithError = func(topic string) (pulsar.Producer, error) {
117-
return &MockPulsarProducer{}, nil
118-
}
115+
fc.outputMessageWithError = testCase.outputFunc
119116

120117
actualProducer, err := fc.NewOutputMessageWithError(publishTopic)
121-
assert.IsType(t, testCase.expectedProducerType, actualProducer)
118+
if testCase.expectedProducerType == nil {
119+
assert.Nil(t, actualProducer)
120+
} else {
121+
assert.IsType(t, testCase.expectedProducerType, actualProducer)
122+
}
122123
assert.Equal(t, testCase.expectedError, err != nil)
123124
})
124125
}

0 commit comments

Comments
 (0)