Close corresponds with the Close method of sarama's SyncProducer implementation. By closing a mock syncproducer, you also tell it that no more SendMessage calls will follow, so it will write an error to the test state if there's any remaining expectations.
()
| 148 | // By closing a mock syncproducer, you also tell it that no more SendMessage calls will follow, |
| 149 | // so it will write an error to the test state if there's any remaining expectations. |
| 150 | func (sp *SyncProducer) Close() error { |
| 151 | sp.l.Lock() |
| 152 | defer sp.l.Unlock() |
| 153 | |
| 154 | if len(sp.expectations) > 0 { |
| 155 | sp.t.Errorf("Expected to exhaust all expectations, but %d are left.", len(sp.expectations)) |
| 156 | } |
| 157 | |
| 158 | return nil |
| 159 | } |
| 160 | |
| 161 | //////////////////////////////////////////////// |
| 162 | // Setting expectations |