I have this exact testing issue at my company, we have many Go services which use Postgres in production, but are unit tested against SQLite.
The latest SQLite covers the vast majority of Postgres queries, so most tests simply use an SQLite in-memory DB. For the tests which require Postgres- specific functionality, such as partitioned tables, for example, we use https://github.com/testcontainers/testcontainers-go. This is a library which talks to Docker and can create your test prerequisites as docker containers and gives you connection information once they're up. This makes unit tests incredibly slower, but at least functional. The danger with mocking too much is that your unit tests end up testing the mocks, and not anything remotely like your runtime environment, so we've chosen to mock as little as possible. -- Marcin On Wed, Jul 28, 2021 at 4:09 AM Henry <henry.adisuma...@gmail.com> wrote: > On Wednesday, July 28, 2021 at 3:05:43 PM UTC+7 amits...@gmail.com wrote: > >> That sounds interesting - is the tool generating or is able to >> generate SQL for different databases? That must have been a pretty big >> effort to create such an abstraction. >> >> > It produces different SQL for different databases. It supports a limited > number of databases. Note that quite a number of Go ORM libraries already > support multiple databases. So it is not new. The difference is that other > ORM libraries usually provide a general purpose data access library, > whereas ours generates more specific codes. Other than that, they serve a > similar purpose. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/9c81746a-4fb4-4fb5-8e5f-605169a3f2afn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/9c81746a-4fb4-4fb5-8e5f-605169a3f2afn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29Lv83-4yDijNmukf0Vx%2BoBVZXJPR11bqA_B5CY1mNhOowA%40mail.gmail.com.