Skip to content

Commit bdc2415

Browse files
committed
Test: improved domain consume operator test, compares callback arg with serialized value
1 parent ead37fd commit bdc2415

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

queue/operator_tests.go

+13
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestSuiteConsumeOperator[InMsg any, Msg any](
3434
var queueName string
3535
var serializer MessageSerializer[InMsg, Msg]
3636
var callbackCount atomic.Int64
37+
var callbackValue Msg
3738
var callback Callback[Msg]
3839

3940
queueName = "testQueueName"
@@ -71,6 +72,13 @@ func TestSuiteConsumeOperator[InMsg any, Msg any](
7172
})
7273

7374
assert.NotNil(t, operator.Serializer(), serializer)
75+
value, err := serializer.Serialize(rawMessageProvider())
76+
if err != nil {
77+
return
78+
}
79+
80+
assert.NotNil(t, value)
81+
assert.Nil(t, err)
7482
})
7583

7684
t.Run("Callback", func(t *testing.T) {
@@ -94,16 +102,21 @@ func TestSuiteConsumeOperator[InMsg any, Msg any](
94102
callbackCount = atomic.Int64{}
95103
callback = func(msg Msg) {
96104
callbackCount.Add(1)
105+
callbackValue = msg
97106
}
98107
operator = operatorProvider(queueName, serializer, callback)
99108
})
100109

101110
msg := rawMessageProvider()
102111
assert.NotNil(t, msg)
103112

113+
expectedSerializedValue, err := serializer.Serialize(msg)
114+
assert.Nil(t, err)
115+
104116
operator.Consume(msg)
105117
assert.Equal(t, serializer.(*mockSerializer[InMsg, Msg]).Count(), int64(1))
106118
assert.Equal(t, callbackCount.Load(), int64(1))
119+
assert.Equal(t, callbackValue, expectedSerializedValue)
107120
})
108121

109122
t.Run("StartConsume", func(t *testing.T) {

0 commit comments

Comments
 (0)