Skip to content

Commit

Permalink
fix: unit test -- TestService_SourceTransformFn_Panic
Browse files Browse the repository at this point in the history
Signed-off-by: adarsh0728 <[email protected]>
  • Loading branch information
adarsh0728 committed Jan 27, 2025
1 parent 147eb7a commit da42e80
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/sourcetransformer/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ func TestService_SourceTransformFn_Multiple_Messages(t *testing.T) {
}

func TestService_SourceTransformFn_Panic(t *testing.T) {
panicMssg := "transformer panicked"
svc := &Service{
Transformer: SourceTransformFunc(func(ctx context.Context, keys []string, datum Datum) Messages {
panic("transformer panicked")
panic(panicMssg)
}),
// panic in the transformer causes the server to send a shutdown signal to shutdownCh channel.
// The function that errgroup runs in a goroutine will be blocked until this shutdown signal is received somewhere else.
Expand Down Expand Up @@ -293,6 +294,6 @@ func TestService_SourceTransformFn_Panic(t *testing.T) {
_, err = stream.Recv()
require.Error(t, err, "Expected error while receiving message from the stream")
gotStatus, _ := status.FromError(err)
expectedStatus := status.Convert(status.Errorf(codes.Internal, errTransformerPanic.Error()))
expectedStatus := status.Convert(status.Errorf(codes.Internal, "%s: %v", errTransformerPanic, panicMssg))
require.Equal(t, expectedStatus, gotStatus)
}

0 comments on commit da42e80

Please sign in to comment.