()
| 133 | } |
| 134 | |
| 135 | func (s *WatcherTestSuite) TestConsumeWithFilter() { |
| 136 | producer, err := watcher.RegisterProducer(s.ctx, "test-producer") |
| 137 | s.Require().NoError(err) |
| 138 | s.Require().NotNil(producer) |
| 139 | |
| 140 | consumer, err := watcher.RegisterConsumer( |
| 141 | s.ctx, "test-consumer", |
| 142 | watcher.WithEntityTypeFilter(common.ControllerEntityType), |
| 143 | watcher.WithOperationTypeFilter(common.UpdateOperation)) |
| 144 | s.Require().NoError(err) |
| 145 | s.Require().NotNil(consumer) |
| 146 | consumeEvents(consumer) |
| 147 | |
| 148 | payload := common.ChangePayload{ |
| 149 | EntityType: common.ControllerEntityType, |
| 150 | Operation: common.UpdateOperation, |
| 151 | Payload: "test", |
| 152 | } |
| 153 | err = producer.Notify(payload) |
| 154 | s.Require().NoError(err) |
| 155 | |
| 156 | receivedPayload := waitForPayload(consumer.Watch(), 100*time.Millisecond) |
| 157 | s.Require().NotNil(receivedPayload) |
| 158 | s.Require().Equal(payload, *receivedPayload) |
| 159 | |
| 160 | payload = common.ChangePayload{ |
| 161 | EntityType: common.ControllerEntityType, |
| 162 | Operation: common.CreateOperation, |
| 163 | Payload: "test", |
| 164 | } |
| 165 | err = producer.Notify(payload) |
| 166 | s.Require().NoError(err) |
| 167 | |
| 168 | receivedPayload = waitForPayload(consumer.Watch(), 100*time.Millisecond) |
| 169 | s.Require().Nil(receivedPayload) |
| 170 | } |
| 171 | |
| 172 | func (s *WatcherTestSuite) TestWithAnyFilter() { |
| 173 | producer, err := watcher.RegisterProducer(s.ctx, "test-producer") |
nothing calls this directly
no test coverage detected