nodece commented on code in PR #24122:
URL: https://github.com/apache/pulsar/pull/24122#discussion_r2015862180


##########
pulsar-function-go/pf/context_test.go:
##########
@@ -82,3 +84,42 @@ func TestFunctionContext_NewOutputMessage(t *testing.T) {
        actualProducer := fc.NewOutputMessage(publishTopic)
        assert.IsType(t, &MockPulsarProducer{}, actualProducer)
 }
+
+func TestFunctionContext_NewOutputMessageWithError(t *testing.T) {
+
+       testCases := []struct {
+               name                 string
+               outputFunc           func(topic string) (pulsar.Producer, error)
+               expectedError        bool
+               expectedProducerType *MockPulsarProducer
+       }{
+               {
+                       name:                 "Test producer",
+                       outputFunc:           func(topic string) 
(pulsar.Producer, error) { return &MockPulsarProducer{}, nil },
+                       expectedError:        false,
+                       expectedProducerType: &MockPulsarProducer{},
+               },
+               {
+                       name:                 "Test error",
+                       outputFunc:           func(topic string) 
(pulsar.Producer, error) { return nil, errors.New("test error") },
+                       expectedError:        false,
+                       expectedProducerType: nil,
+               },
+       }
+
+       for i, testCase := range testCases {
+               t.Run(fmt.Sprintf("testCase[%d] %s", i, testCase.name), func(t 
*testing.T) {
+
+                       fc := NewFuncContext()
+                       publishTopic := "publish-topic"
+
+                       fc.outputMessageWithError = func(topic string) 
(pulsar.Producer, error) {
+                               return &MockPulsarProducer{}, nil
+                       }

Review Comment:
   ```suggestion
                        fc.outputMessageWithError = testCase.outputFunc;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to