INNER CODE UNIT · Go
func
owlistic-notes/owlistic · src/backend/broker/consumer_test.go:29
func (m *MockConsumer) ReadMessage(timeoutMs int) (*nats.Msg, error) {
if m.closed {
// Use a standard error code instead of ErrConsumerClosed which doesn't exist
return nil, nats.ErrConnectionClosed
}
if len(m.messages) == 0 {
return nil, nats.ErrConsumerNotActive
}
msg := m.messages[0]
m.messages = m.messages[1:]
return msg, nil
}
func (m *MockConsumer) Close() {
m.closed = true
}