@@ -338,8 +338,8 @@ func TestStart(t *testing.T) {
338338
339339 queued1 := client .QueueMessage (& chipingress.CloudEventPb {Id : "test-id-1" , Source : "test-source" , Type : "test.event.type" }, nil )
340340 queued2 := client .QueueMessage (& chipingress.CloudEventPb {Id : "test-id-2" , Source : "test-source" , Type : "test.event.type" }, nil )
341- require .True (t , queued1 )
342- require .True (t , queued2 )
341+ require .NoError (t , queued1 )
342+ require .NoError (t , queued2 )
343343
344344 select {
345345 case <- done :
@@ -813,4 +813,35 @@ func TestStop(t *testing.T) {
813813 client .Stop ()
814814 client .Stop ()
815815 })
816+
817+ t .Run ("QueueMessage returns error after Stop" , func (t * testing.T ) {
818+ mockClient := mocks .NewClient (t )
819+ client , err := NewBatchClient (mockClient , WithBatchSize (10 ))
820+ require .NoError (t , err )
821+
822+ ctx , cancel := context .WithCancel (t .Context ())
823+ defer cancel ()
824+
825+ client .Start (ctx )
826+
827+ // Queue message before stop - should succeed
828+ err = client .QueueMessage (& chipingress.CloudEventPb {
829+ Id : "test-id-1" ,
830+ Source : "test-source" ,
831+ Type : "test.event.type" ,
832+ }, nil )
833+ require .NoError (t , err )
834+
835+ // Stop the client
836+ client .Stop ()
837+
838+ // Queue message after stop - should fail
839+ err = client .QueueMessage (& chipingress.CloudEventPb {
840+ Id : "test-id-2" ,
841+ Source : "test-source" ,
842+ Type : "test.event.type" ,
843+ }, nil )
844+ require .Error (t , err )
845+ assert .Contains (t , err .Error (), "shutdown" )
846+ })
816847}
0 commit comments