Closed khanzf closed 2 years ago
Figured it out by looking at the source.
For anyone else reading this:
The NewMockPgxPool
section sets up the pool, while the NewRows
defines a row that could be returned. The EXCEPT/Query()
line defines what a query would look like and what should be returned.
The orderDao
lines are setting up and running the actual test, while the final GetORderByID
is the execution of the test.
Hi, I read the example and looked up other use cases on github, but I do not understand what is happening after this line:
It seems to me that the code is defining the table, then populating it with 2 values (the ID and integer). But what happens afterwards? What does this line do:
I see 3 arguments of Query(), but I do not understand that. Afterwards, I see this line:
What is
orderDao
and why is it populated this way?Ultimately, my objective is to figure out how to unit-test a Query() that uses pgxpool. Thank you!