-
-
Notifications
You must be signed in to change notification settings - Fork 67
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
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:
func (c *pgxmock) SendBatch(context.Context, *pgx.Batch) pgx.BatchResults {
return nil
}Best assertion I can do is assert that the queued batch length is greater than 0.
Checklist
-
pgxmock.go
- Add a new type
ExpectedBatchwith fields for the expected SQL statements and their arguments, and methods to set the expected results or errors.
• Modify theSendBatchmethod to return mock batch results based on the queued expectations.
• Add a new methodExpectBatchto thepgxmocktype to queue an expected batch operation. This method should return anExpectedBatchinstance.
• Update theExpectationsWereMetmethod to also check if all expected batch operations were met.
-
pgxmock_test.go
- Add unit tests for the new
ExpectBatchmethod and the modifiedSendBatchmethod. 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested