Closed acline443 closed 1 year ago
Yes, unfortunately, SendBatch()
is not currently supported. I do have plans for it. However, this will require some spare weeks to implement. One needs to implement pgx.BatchResults from scratch and incorporate this into the expectations paradigm. Of course, pull requests are more than welcome!
Details
I may be misusing the library, so correct me if I am wrong. But I would like to write unit tests for functions that queue batches and then send the batch at the end. I would like to assert on the Updates/Insertions that are executed.
It seems to me like this is not currently supported as the SendBatch method does basically nothing:
Best assertion I can do is assert that the queued batch length is greater than 0.
Checklist
- [X] `pgxmock.go` > * Add a new type `ExpectedBatch` with fields for the expected SQL statements and their arguments, and methods to set the expected results or errors. > • Modify the `SendBatch` method to return mock batch results based on the queued expectations. > • Add a new method `ExpectBatch` to the `pgxmock` type to queue an expected batch operation. This method should return an `ExpectedBatch` instance. > • Update the `ExpectationsWereMet` method to also check if all expected batch operations were met. - [ ] `pgxmock_test.go` > * Add unit tests for the new `ExpectBatch` method and the modified `SendBatch` method. These tests should cover various scenarios, including successful batch operations, batch operations that result in errors, and batch operations that do not meet the expectations.